7

I've attached some events to some divs using addEventListener. But where can I see the events in Firebug?

bluish
  • 26,356
  • 27
  • 122
  • 180
Florian Müller
  • 7,448
  • 25
  • 78
  • 120

3 Answers3

12

If you are using jQuery, then install FireQuery, it shows all bound events on the HTML DOM panel per element. Very useful addition.

Orbling
  • 20,413
  • 3
  • 53
  • 64
  • Additionally it shows up any data you store, and provides a "jqueryify" button on the console for injecting the current version of jQuery on to the page you are viewing, which is very useful. – Orbling Nov 18 '10 at 15:43
  • 1
    Thanks for this. FireQuery is an excellent tool and well worth intsalling for any web developer using jQuery with Firebug. – crmpicco Oct 11 '13 at 09:45
  • 1
    It looks like it stopped working at some point... I use the newest version of jQuery and I could not see anything with that extension. – Alexis Wilke Aug 03 '14 at 06:31
7

It's probably worth mentioning that Firebug 1.12 introduced getEventListeners(target). The Firebug wiki page for it is here, and there's 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 posted.)

However, there are a couple of caveats for getEventListeners:

First off, it won't work if you pass it a jQuery object; pass it a normal DOM object instead. (Perhaps this is obvious, but it caught me out!)

Secondly, I've found that getEventListeners doesn't always work if I run it before all code on a page has loaded. I'm not sure exactly when it does and doesn't work, but I've certainly seen a situation like this:

>>> 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 post linked to in the answer) can retrieve the event, but getEventListeners is showing up as not defined. This error is different to the return value you get if getEventListeners runs but reports that an object has no listeners, so I'd say you can use getEventListeners without fear, as it'll be obvious if it's not yet available!

Sam
  • 5,997
  • 5
  • 46
  • 66
1

Don't think Firebug has good functionality for that. You might wanna look here.

Community
  • 1
  • 1
Mark Baijens
  • 13,028
  • 11
  • 47
  • 73