<html>
<body>
<p>用户点击后使用 addEventListener() 方法来执行函数。</p>
<button id="myBtn">点我</button>
<p id="demo">
<script>
document.getElementById("myBtn").addEventListener("click", myFunction);
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
}
</script>
</p></body>
</html>