<html>
<body>
<p>This document has an onmousemove event handler that displays a random number every time you move your mouse in this document.</p>
<p>Click the button to remove the event handler.</p>
<button onclick="removeHandler()">Try it</button>
<p><strong>Note:</strong> The addEventListener() and removeEventListener() methods are not supported in Internet Explorer 8 and earlier versions.</p>
<p id="demo"></p>
<script>
document.addEventListener("mousemove", myFunction);
function myFunction() {
document.getElementById("demo").innerHTML = Math.random();
}
function removeHandler() {
document.removeEventListener("mousemove", myFunction);
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_addeventlistener_remove by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:01:39 GMT -->
</html>