document.removeEventListener() example 1
RUN
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> #result{ color: red; font-size: 20px; font-weight: bold; } </style> <body> <h1>Học lập trình miễn phí tại freetuts.net</h1> <p id="result"></p> <button onclick="removeHandler()">Remove event</button> <script> document.addEventListener("mousemove", myFunction); function myFunction() { document.getElementById("result").innerHTML = Math.random(); } function removeHandler() { document.removeEventListener("mousemove", myFunction); } </script> </body> </html>
PHÓNG TO