I'm using jquery ui sortable. When the rows are rearranged I want to reset the row colors to zebra striped. This is the code I'm using.
function reset_rows() {
$("#rank tbody tr").removeClass("row1","row2");
$("#rank tbody tr:even").addClass("row1");
}
$("#rank tbody").sortable({
update : function() {
reset_rows();
}
});
The function adds the correct row colors then removes them all immediately. How can I get jquery to remove the row classes first then add back the row1 class to the even rows? It adds the row1 class first regardless of what order I use the functions in the code.