[jQuery] jquery code snippit improvement request
Here is a bit of code that on page load sets the alternating color of
a table.
Then there is a table sort tool that loads as well. The th (header)
clicks cause the nice alternating line colors to sort as well. So I
created this, which works perfect, but it looks clunky/repetitive..
I was thinking about wrapping an if statement in here somewhere, or
maybe there is something else other people can think of.
<script type="text/javascript">
$(document).ready(function()
{
$('tbody.bevker tr:odd').removeClass();
$('tbody.bevker tr:even').removeClass();
$('tbody.bevker tr:odd').addClass('row0 odd');
$('tbody.bevker tr:even').addClass('row1 even');
$('th').click(function()
{
$('tbody.bevker tr:odd').removeClass();
$('tbody.bevker tr:even').removeClass();
$('tbody.bevker tr:odd').addClass('row0 odd');
$('tbody.bevker tr:even').addClass('row1 even');
return false;
}
);
}
);
</script>