运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The Window Object</h1> <h2>The addEventListener() Method</h2> <p>This example adds many events on the window.</p> <p id="demo"></p> <script> window.addEventListener("mouseover", myFunction); window.addEventListener("click", mySecondFunction); window.addEventListener("mouseout", myThirdFunction); function myFunction() { document.getElementById("demo").innerHTML += "Moused over! " } function mySecondFunction() { document.getElementById("demo").innerHTML += "Clicked! " } function myThirdFunction() { document.getElementById("demo").innerHTML += "Moused out! " } </script> </body> </html>