AndreasKnudsen
AndreasKnudsen

Reputation: 3481

JQuery: how do I see which events are defined on an element?

I use

$(window).bind( ... )

to set up event handlers, but for some reason I keep losing event handlers (i think). Is there any way when debugging (firebug) to see which custom events have been added to a given element?

Yours Andreas

Upvotes: 3

Views: 735

Answers (1)

redsquare
redsquare

Reputation: 78667

All events bound by jQuery (e.g not inline events) can be accessed through .data

var $el = $('#someId');
var allEvents =  $.data( $el , "events" );

or

$('#someId').data('events');

its very rare I bind events to the window object but the same notion should still apply so try $(window).data('events')

This does indeed work demo here (writes to console so use firefox + firebug)

Upvotes: 9

Related Questions