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
http://www.quirksmode.org/js/events_advanced.html – “Which event handlers are registered?” – it seems it’s not possible without DOM 3 level 🙁
EDIT: I’ve come up with this code. It suits my needs. Maybe it will be helpful for someone else.
Javascript:
Testing HTML page: