I have 2 tables and would like alternating row colors to reset based on a new table. the tr:odd
seems to be applied across both of my tables.
Here's my table html:
<table class='myTable'>
<tr class='myRow'>
<td>row 1</td>
</tr>
<tr class='myRow'>
<td>row 2</td>
</tr>
<tr class='myRow'>
<td>row 3</td>
</tr>
</table>
<hr>
<table class='myTable'>
<tr class='myRow'>
<td>row 1</td>
</tr>
<tr class='myRow'>
<td>row 2</td>
</tr>
</table>
css:
.myAltRowClass { background: #DDDDDC; }
javascript:
$(".myTable .myRow:odd").addClass('myAltRowClass');
jsfiddle: http://jsfiddle.net/niner/Sgq9T/
The 1st table and 2nd table both have alternating colors, but the 1st row in table 2 should start out with the normal (white) color, and not the alternate (grey) color.
I would appreciate any help. Thanks.