运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The Window Object</h1> <h2>The addEventListener() Method</h2> <p>This example adds two click events to the window.</p> <p>Click anywhere in the document.</p> <p id="demo"></p> <script> window.addEventListener("click", myFunction1); window.addEventListener("click", myFunction2); function myFunction1() { document.getElementById("demo").innerHTML += "First function was executed! " } function myFunction2() { document.getElementById("demo").innerHTML += "Second function was executed! " } </script> </body> </html>