我有一個表像這樣:JQuery的 - 添加類,這並不包含一個類名的每個表替換錶行
<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");
這仍然將它添加到每一個偶數行。
這工作!我確信其他人工作,但這是我第一次嘗試,謝謝人們!當我也能接受時,我會接受這個答案! – CallumVass 2012-02-09 14:40:56