/ Published in: jQuery
.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):
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):
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$("#dataTable tbody").on("click", "tr", function(event){ alert($(this).text()); }); ///// function notify(){ alert("clicked"); } $("button").on("click", notify);
URL: http://api.jquery.com/on/