Using:
$('#foo').data('events').click
We are able to access an iterative object of click handlers added to the element ‘#foo’ but only when they were added with .bind()
Is there a way to get the handlers for an event added with .live()?
Is there any other way to know if an element has a click handler assigned?
liveevents are added to the document. UseThe above will return an array of objects containing information about each bound click handler. Each of these objects has a
selectorproperty containing the selector that was used at the time of binding with$(selector).live(.., ..).Any of these selectors that matches the element with id foo will get triggered when
#foois clicked. Note that the selector does not have to be exactly#foofor that to happen. There are many other selectors that can be used to target an element. For example if#foowas a<p>, then a live click handler such aswill also target
#foo.Here’s one approach. Loop through each object, and see if any of the elements matching the
selectorproperty include#foo.