I have a page where some event listeners are attached to input boxes and select boxes. Is there a way to find out which event listeners are observing a particular DOM node and for what event?
Events are attached using:
- Prototype's
Event.observe
; - DOM's
addEventListener
; - As element attribute
element.onclick
.
Chrome, Firefox, Vivaldi and Safari support
getEventListeners(domElement)
in their Developer Tools console.For majority of the debugging purposes, this could be used.
Below is a very good reference to use it: https://developers.google.com/chrome-developer-tools/docs/commandline-api#geteventlistenersobject
Opera 12 (not the latest Chrome Webkit engine based) Dragonfly has had this for a while and is obviously displayed in the DOM structure. In my opinion it is a superior debugger and is the only reason remaining why I still use the Opera 12 based version (there is no v13, v14 version and the v15 Webkit based lacks Dragonfly still)
You could wrap the native DOM methods for managing event listeners by putting this at the top of your
<head>
:H/T @les2
If you have Firebug, you can use
console.dir(object or array)
to print a nice tree in the console log of any JavaScript scalar, array, or object.Try:
or
I am trying to do that in jQuery 2.1, and with the "
$().click() -> $(element).data("events").click;
" method it doesn't work.I realized that only the $._data() functions works in my case :