0

我想在表格的第一列上制作斑马效果。我怎么能选择 tr 的第一个 td 并在其上应用 nth-child(2n) ?

4

2 回答 2

2

:nth-child()伪类到tr,伪:first-child类到td

$('tr:nth-child(2n) td:first-child').css('background-color', '#ccc');
于 2011-08-03T15:28:21.273 回答
0

您需要添加nth-child(2n)<tr>然后使用:first-child来仅选择第一个<td>。在这里查看:

http://jsfiddle.net/ajthomascouk/WtLek/

于 2011-08-03T15:35:42.527 回答