Firebug: How to see attached events of an object?

I bound some events to some divs using addEventListener . But where can I see events in Firebug?

+7
javascript firebug
source share
3 answers

It might be worth mentioning that Firebug 1.12 introduced getEventListeners(target) . The Firebug Wiki page for this is here , and there is a very useful blog post about it here .

(Firebug 1.12 was only released in August 2013, so the answer to this question was right when it was originally published.)

However, there are a few caveats for getEventListeners :

First of all, this will not work if you pass it a jQuery object; pass it a regular DOM object. (Perhaps this is obvious, but it caught me!)

Secondly, I found that getEventListeners does not always work if I ran it before all the code on the page loaded. I am not sure exactly when this happens and does not work, but of course I saw this situation:

 >>> getEventListeners(document.getElementById('elementid')) ReferenceError: getEventListeners is not defined >>> $._data(document.getElementById('elementid'), "events"); Object { click=[1]} 

As you can see, the longhand method (from the SO message associated with the response) may receive the event, but getEventListeners displayed as undefined. This error is different from the return value if getEventListeners works, but reports that the object has no listeners, so I would say that you can use getEventListeners without fear, as this will be obvious if it is not already available!

+7
source share

If you use jQuery, then install FireQuery , it displays all the related events in the HTML DOM panel for each element. A very useful addition.

+12
source share

Do not think that Firebug has good functionality. You can look here .

+1
source share

All Articles