<!DOCTYPE html> <html> <body> <h1>Element 对象</h1> <h2>addEventListener() 方法</h2> <p>将 click 事件附加到按钮:</p> <button id="myBtn">试一试</button> <p id="demo"></p> <script> const element = document.getElementById("myBtn"); element.addEventListener("click", function() { document.getElementById("demo").innerHTML = "Hello World"; }); </script> </body> </html>