Possible Duplicate:
How to find event listeners on a DOM node?
Given an element, let's say a div
, is it possible to obtain a list of the handlers bound to a specific event fired by the element?
/* pseudo code: click on a div handlers? */
document.getElementById('myDiv').getHandlers('click');
Edit
Ok, here's some more details. I want to bind a click handler to a div, unless another handler is already bound to the div. What I have in mind is the following:
/* pseudo code: click on a div handlers? */
if(!document.getElementById('myDiv').getHandlers('click'))
document.getElementById('myDiv').addEventListener('click', myEventhandler);
No, it is not possible with DOM methods.
However, some libraries store all handlers they bind in element-associated data structures to enable methods like unbindAll
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With