Event Delegation with jQuery Example using .live()
Thursday, March 4, 2010
Click on any of the rows in the table to toggle a highlight. This example is using the `.live()` 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($) {
$('tr').live('click', function() {
$(this).toggleClass('selected');
});
});