I took an html table that I am applying alternative row colors to, and I added jquery table sorter on it so users can sort the table.
The issue is that the alternati
Based on Anthony's answer, but rephrased as a one-liner (mostly):
function fixStripes() {
$('table tr').removeClass('odd even')
.filter(':even').addClass('even').end()
.filter(':odd').addClass('odd');
}
$("table").bind("sort", fixStripes);
JQuery calls can be "chained" as above, using operations like filter() to limit the selected elements, and .end() to "reset" to the last selection. Put another way, each .end() "undoes" the previous .filter(). The final .end() is left off, since there's nothing to do after that.