Toggling row colors
- by cf_PhillipSenn
I have a table cell in the footer that allows the user to turn on row coloring:
$('#highlight').click(function() {
$(this).parents('table').RowColors();
})
// From Chapter 7 of Learning jQuery
$.fn.RowColors = function() {
$('tbody tr:odd', this).removeClass('even').addClass('odd');
$('tbody tr:even', this).removeClass('odd').addClass('even');
return this;
};
Q: How do I write a selector that says: IF there is at least 1 row with class="even", then remove both "even" and "odd" ELSE execute the RowColors function.