Jump to content

removeEventListener


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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...