I\'m having several div\'s #mydiv1, #mydiv2, #mydiv3, ... and want to assign click handlers to them:
#mydiv1
#mydiv2
#mydiv3
$(document).ready
$(document).ready(function(){ for(var i = 0; i < 5; i++) { var $li= $('' + i +''); (function(i) { $li.click( function(){ alert('you clicked ' + i); }); }(i)); $('#ul').append($li); } });