I am trying to exclude nested tables from my table striping (making every other row a different bg color). Here is my code to stripe the table:
$(".stripeTable tbody tr:odd").addClass("stripe");
My question is, how to I prevent the nested table’s odd rows from receiving the class “stripe”?
Here’s the generated code from the browser, I want to remove the class=”stripe” from the nested table.
<table>
<tr>
<td>My Table Cell </td>
</tr>
<tr class="stripe">
<td>
<table>
<tr>
<td>My nested table cell</td>
</tr>
<tr class="stripe">
<td>my nested table cell (remove the stripe!)</td>
</tr>
</table>
</td>
</tr>
</table>
If only the top-level table has the
stripeTableclass, just add some child selectors>:If the nested tables have the
stripeTableclass as well, you may need to anchor.stripeTableto another parent element with another child selector: