I think you could do something like this: you save the div events by cloning the div and storing the data (βeventsβ) in the object. Afterword you iterate over an object and bind events. You have to clone, because when you unbind events, the original data ("events") is deleted (I hope I understand what you are looking for)
<div id='my'>my</div> var my = $('#my'); my.click(function(){ alert('my'); }); my.hover(function(){ $(this).css('color', 'red'); }); my.click(function(){ alert('you'); }); var ev =my.clone(true).data('events'); my.unbind(); for (var e in ev){
fidlle http://jsfiddle.net/pXAXW/
EDIT. To do this work in 1.5.2, you just need to change the way events are bound, because they are saved in different ways:
$(document).ready(function(){ var theDiv = $("#thediv"); theDiv.click(function(){ $(this).css("border-color", "blue"); alert("Click!"); }); theDiv.click(function(){ $(this).css("border-color", "blue"); alert("clack!"); }); var theEvents = theDiv.clone(true).data("events");
fiddle here: (just like Katiek) http://jsfiddle.net/nicolapeluchetti/CruMx/2/ (the event fires twice if you donβt click on the div!) I also updated my script to use jquery 1.5. 2 http://jsfiddle.net/pXAXW/1/ )
source share