jQuery Access Internal Event-related Data through _data() method

jQuery internally stores and maintains the list of events which was attached or detached from DOM elements. Meanwhile, jQuery data mechanism jQuery._data() – the “undocumented” method – which allow us to access the jQuery internal event-related data structure.

As of jQuery 1.8, the event data is no longer available from the “public API” for data. you must use the ‘private data’ method: jQuery._data() instead of jQuery( element ).data( "events" );

.data(“events”): jQuery stores its event-related data in a data object named (wait for it) events on each element. This is an internal data structure so in 1.8 this will be removed from the user data name space so it won’t conflict with items of the same name. jQuery’s event data can still be accessed via jQuery._data(element, "events") but be aware that this is an internal data structure that is undocumented and should not be modified.

The latest unofficial (but works in previous versions as well, at least in 1.7.2) way of doing it now is

element should be an HTML Element, not a jQuery object, or selector. For example:



The underscore (“_”) is what makes the difference here. Internally, it is calling $.data(element, name, null, true), the last (fourth) parameter is an internal one (“pvt”).

Please note, that this is an internal, ‘private’ structure, and shouldn’t be modified. Use this for debugging purposes only.

In older versions of jQuery, you might have to use the old method which is:

In a modern browser with ECMAScript 5.1 / Array.prototype.map, you can also use below in your browser console, which will print the source of the handlers, comma delimited. Useful for glancing at what all is running on a particular event