Event Delegation with jQuery Example using .delegate()
Thursday, March 4, 2010
Click on any of the rows in the table to toggle a highlight. This example is using the `.delegate()` method.
| 1 | Lorem ipsum dolor sit amet |
| 2 | Lorem ipsum dolor sit amet |
| 3 | Lorem ipsum dolor sit amet |
| 4 | Lorem ipsum dolor sit amet |
| 5 | Lorem ipsum dolor sit amet |
| 6 | Lorem ipsum dolor sit amet |
Example Code
jQuery(function($) {
$('table').delegate('tr', 'click', function() {
$(this).toggleClass('selected');
});
});