Return to Snippet

Revision: 60304
at October 31, 2012 19:35 by grindking


Initial Code
$("#dataTable tbody").on("click", "tr", function(event){
	alert($(this).text());
});




/////
function notify(){
       alert("clicked"); 
}

$("button").on("click", notify);

Initial URL
http://api.jquery.com/on/

Initial Description
.on( events [, selector] [, data], handler(eventObject) )

A delegated-events approach attaches an event handler to only one element, the tbody, and the event only needs to bubble up one level (from the clicked tr to tbody):

Initial Title
.on() - jquery event handler

Initial Tags
event, jquery

Initial Language
jQuery