HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ width:auto; height:200px; border:1px solid black; padding:10px; } </style> </head> <body> <div>Move your mousepointer over here. <p>Click on the button to remove 'addEventListener()' Method.</p> <button onclick="myFunction()">Click Me</button> <p id="point"></p> </div> <script> var x = document.getElementById("point"); var elem = document.getElementsByTagName("div")[0]; function pointerFunction(e){ var xCoords = e.clientX; var yCoords = e.clientY; var result = "X coords = "+xCoords+" ,Y coords = "+yCoords; x.innerHTML = result; } function myFunction(){ elem.removeEventListener("mousemove",pointerFunction) } elem.addEventListener("mousemove",pointerFunction) </script> </body> </html>
OUTPUT
×

Save as Private