You can add events of different types to the document.
This example demonstrates how to add many events to the document:
<!DOCTYPE html> <html> <body> <p>This example uses the addEventListener() method to add many events on the document.</p> <p id="demo"></p> <script> document.addEventListener("mouseover", myFunction); document.addEventListener("click", mySecondFunction); document.addEventListener("mouseout", myThirdFunction); function myFunction() {/*from ww w. j a v a 2 s. c o m*/ document.getElementById("demo").innerHTML += "Moused over!<br>" } function mySecondFunction() { document.getElementById("demo").innerHTML += "Clicked!<br>" } function myThirdFunction() { document.getElementById("demo").innerHTML += "Moused out!<br>" } </script> </body> </html>