Is there a way to find all of the events for a element in javascript? or a way to unbind all events from a element?
Thanks.
Is there a way to find all of the events for a element in javascript? or a way to unbind all events from a element?
Thanks.
If you don't want ot use jQuery, a quick and dirty way (and there's bound to be a better one) would be to loop through the element's parameters and check for functions that begin with 'on' (onclick etc).
There is not way to do that directly using javascript.
Jquery has a couple of functions to keep track of that data.
One "pure" way to do that is to change the addEventListener/attachEvent function through prototyping (search about javascript prototype stuff, not the framework).
Or if you have a custom function to hadle adding/removing events you can tune it.
Well, that's it.
Of course ! Take a look at this to bind/unbind events http://api.jquery.com/category/events/ and use this jQuery code fragment to get all the events bound to an element in the form of a hashset of keypairs "eventname/function delegate"