我有一个像这样的表:
<table>
<tr><td>Row 1</td></tr>
<tr class="special"><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr class="special"><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
<tr class="special"><td>Row 3</td></tr>
</table>
我想做的是在不包含特殊类的每个备用行上使用斑马图案。我尝试了这个,但它不起作用:
$("table tr:not(.special):nth-child(even)").addClass("alt-row");
这仍然将其添加到每个偶数行。
最佳答案
尝试以下操作:
$("table tr").not('.special').filter(':even').addClass("alt-row");
关于JQuery - 将类添加到不包含类名的每个表备用表行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9212628/