http://jsfiddle.net/iambriansreed/xu2AH/9/
.table-striped class
.table-striped tbody tr.highlight td { background-color: red; }
… and cleaner jQuery:
$('#mytable tbody tr').live('click', function(event) {
$(this).addClass('highlight').siblings().removeClass('highlight');
});
Update: .live()
has since been deprecated. Use .on()
.
$('#mytable').on('click', 'tbody tr', function(event) {
$(this).addClass('highlight').siblings().removeClass('highlight');
});