Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to 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>