📜  单击按钮更改 innerHtml - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:05.157000             🧑  作者: Mango

代码示例1
Example-1:
const btn = document.querySelector(".btn");
const heading = document.querySelector(".heading");
btn.addEventListener("click", function () {
  heading.innerHTML = "Hello";
});


Example-2:

_e('btn').addEventListener('click', function() {
    _e('demo').innerHTML = 'Hey There';
}, false);

function _e(id) {
   return document.getElementById(id);
}