Javascript examples for DOM:Document addEventListener
Use addEventListener() to execute a function when a user clicks anywhere in the document.
<!DOCTYPE html> <html> <body> <p id="demo"> <script> document.addEventListener("click", myFunction); function myFunction() {//from w w w . j a va2s . c o m document.getElementById("demo").innerHTML = "Hello World"; } </script> </body> </html>