Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript remove all event listeners

That is not possible without intercepting addEventListener calls and keep track of the listeners or use a library that allows such features unfortunately. It would have been if the listeners collection was accessible but the feature wasn't implemented.

The closest thing you can do is to remove all listeners by cloning the element, which will not clone the listeners collection.

Note: This will also remove listeners on element's children.

var el = document.getElementById('el-id'),
    elClone = el.cloneNode(true);

el.parentNode.replaceChild(elClone, el);
Comment

remove all event listener from elemet

var old_element = document.getElementById("btn");
var new_element = old_element.cloneNode(true);
old_element.parentNode.replaceChild(new_element, old_element);
Comment

PREVIOUS NEXT
Code Example
Javascript :: js push array into array 
Javascript :: how to count the rows of gridview in asp.net using jquery 
Javascript :: react native dotenv 
Javascript :: find multiple javascript 
Javascript :: using regex in javascript 
Javascript :: how to remove last element of array in javascript 
Javascript :: math power javascript 
Javascript :: render react component 
Javascript :: save networkx graph to json 
Javascript :: javascript change video poster 
Javascript :: inbuilt javascript functions for last word check 
Javascript :: var x = 
Javascript :: random function in javascript 
Javascript :: add days to date javascript dd/mm/yyyy in input date 
Javascript :: base64 encode in javascript 
Javascript :: how to add a white space in jsx 
Javascript :: string length in javascript 
Javascript :: export component react 
Javascript :: remove spaces from string javascript 
Javascript :: nodejs process code 
Javascript :: How to make HTML input tag only accept numerical values? in jsx 
Javascript :: javascript comparison operators 
Javascript :: react hello world 
Javascript :: axios post request with authorization header and body 
Javascript :: get react form input data, How get form input data in react 
Javascript :: jquery onlcikc css 
Javascript :: javascript get character from string 
Javascript :: React-redux and redux 
Javascript :: webpack build watch 
Javascript :: angular ng-click toggle class 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =