Javascript examples for DOM:Document addEventListener
Document addEventListener() Method - Use removeEventListener() to remove an event handler attached by addEventListener() method:
<!DOCTYPE html> <html> <body> <button onclick="removeHandler()">Test</button> <p id="demo"></p> <script> document.addEventListener("mousemove", myFunction); function myFunction() {//from w ww . j a v a 2s .c o m document.getElementById("demo").innerHTML = Math.random(); } function removeHandler() { document.removeEventListener("mousemove", myFunction); } </script> </body> </html>