avireni
4/13/2012 - 11:17 PM

set an event handler for any element that matches a selector

set an event handler for any element that matches a selector


$('button.someClass').live('click', someFunction);
	//Note that in jQuery 1.4.2, the delegate and undelegate options have been
	//introduced to replace live as they offer better support for context
    //For example, in terms of a table where before you would use..
	// .live()
	$("table").each(function(){
	  $("td", this).live("hover", function(){
		$(this).toggleClass("hover");
	  });
	});
	//Now use..
	$("table").delegate("td", "hover", function(){
  $(this).toggleClass("hover");
});