Many thanks to Firebug team, who gives their essential time developing an immensely beautiful addon. New version of Firebug lets you find out and trace events bound to elements in the DOM.
See the screenshot (Events tab), in the HTML tab, inspect any Element, you will see 5 tabs with related information to that element on the right side.
Style, Computed, Layout, DOM, Events. Name of tab says what it does. Here we will discuss on last Events tab.
Inspect any element, the in HTML tab click on Events tab located in the right panel. It will show all the events bounded to that element.
There are different groups, like without group on top, then Listeners from Document, Other listeners for Document, Other listeners for Window.
- Group with prefix “Other listeners” are for those specified object like Document, Window etc.
- And starting from “Listeners from” are Event listeners for selected element from that particular Object.
Confused ? See Example below.
// event listener direct to element
// event listener from Document
As you can see in screenshot above, Now you know what they stands for. “Event directly
to element” and “Event to Element
In this example in second code technique used is called "Event delegation", I prefer using this every time if possible. Because its advantage is if DOM is modified and new elements are added, these events still triggers.
What Next ?
When you found event to element,
- you can click on that and it will take you to the source.
- A name on the right side in blue color indicates file name and line number in which event is written.
- Clicking on that link will take you to the event, and hover over shows path where file is located.
To play around, here below is a full example embedded, inspect
tag and look for events.