I was wondering if there is any way to automatically retrieve all elements (or jQuery selectors) that have been bound to a custom events?
In others words, I have bound the following elements to the event “something_added”:
$('div#slider').bind('something_added',function(){});
$('input#add').bind('something_added',function(){});
Anyway to automatically retrieve $('div#slider') and $('input#add') using the event name (‘something_added’)?
You can select all elements and traverse their collection of events, looking for the event you are interested in :
not sure if it works in jquery 1.8
update: here is an example I put together : http://jsfiddle.net/nicholmikey/sADZU/5/
and the jquery (1.7.2):
Once you find an element that has the event you are looking for, you can use $(this) as it relates to the each($(‘*’)) and do the work you are looking to do