Javascript examples for DOM:Document addEventListener
Document addEventListener() Method - Add different type of events to the document.
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> document.addEventListener("mouseover", myFunction); document.addEventListener("click", mySecondFunction); document.addEventListener("mouseout", myThirdFunction); function myFunction() {//from w w w. j a v a 2 s .c om 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>