Is it possible to remove all event handlers of a given element in javascript?
Posted
by MartyIX
on Stack Overflow
See other posts from Stack Overflow
or by MartyIX
Published on 2010-05-14T20:52:10Z
Indexed on
2010/05/14
20:54 UTC
Read the original article
Hit count: 186
Hi,
I would like to remove ALL handlers for a given event type. Let's say I've added twice "onclick event" to a button and now I would like to return back to the original state where no event handler was set to the button.
How can I do that?
P.S.: I've found removeEventListener (non-IE)/detachEvent (IE) methods but the functions want me to pass as a parameter the function that handles the event which seems to me quite clumsy because I would have to store the functions somewhere.
EDIT: http://ejohn.org/blog/flexible-javascript-events/ - I'm now using this code
Thank you!
© Stack Overflow or respective owner