
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to work with removeEventListener() method in JavaScript?
Use the removeEventListener() method in JavaScript to remove event handler attached with addEventListener() method.
Example
<!DOCTYPE html> <html> <head> <style> #box { background-color: gray; border: 2px dashed; } </style> </head> <body> <div id="box">Demo Text! <p>Click below to remove event handler.</p> <button onclick="removeEvent()" id = "btnid">Remove</button> </div> <p id="pid"></p> <script> document.getElementById("box").addEventListener("mousemove", display); function display() { document.getElementById("pid").innerHTML = Math.random(); } function removeEvent() { document.getElementById("box").removeEventListener("mousemove", display); } </script> </body> </html>
- Related Articles
- JavaScript removeEventListener() method with examples
- How to work with addEventListener() method in JavaScript HTML DOM?
- HTML DOM removeEventListener() Method
- How to work with jQuery.closest() method in jQuery?
- How to work with document.anchors in JavaScript?
- How to work with document.body in JavaScript?
- How to work with document.embeds in JavaScript?
- How to work with document.documentElement in JavaScript?
- How to work with document.head in JavaScript?
- How to work with document.forms in JavaScript?
- How to work with document.images in JavaScript?
- How to work with document.links in JavaScript?
- How to work with document.title in JavaScript?
- How to work with Structs in JavaScript?
- How to work with delete operator in JavaScript?

Advertisements