Jump to content

removeEventListener


jimfog
 Share

Recommended Posts

I want to remove the clickhandler from this element here https://jsfiddle.net/fiddlehunt/gvtLd3e9/40/...a tooltip is attached to it.

No jquery is used here..so I must resort to nativeJS...namely removeListener.

 

I know that to use removeListener I must know the method/function used originally in the addeventListener..which I do not.

SO...what  can I do to remove the listener?

Link to comment
Share on other sites

Unfortunately, you can only remove listeners is you have access to the function which was assigned as the event handler.

This "tippy" library, if it was built properly, must have some methods to remove tooltips. If not, then your only hope is to recreate the element and delete the old one.
 

// Get the old element
var old = document.getElementById("tippy_test");

// Create a new element
var replacement = document.createElement("div");
replacement.id = "tippy_test";
replacement.innerHTML = old.innerHTML;

// Replace the old element with the new one
old.parentNode.insertBefore(replacement, old);
old.parentNode.removeChild(old);

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...