Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在表格的第一列上制作斑马效果。我怎么能选择 tr 的第一个 td 并在其上应用 nth-child(2n) ?
:nth-child()伪类到tr,伪:first-child类到td:
:nth-child()
tr
:first-child
td
$('tr:nth-child(2n) td:first-child').css('background-color', '#ccc');
您需要添加nth-child(2n)到<tr>然后使用:first-child来仅选择第一个<td>。在这里查看:
nth-child(2n)
<tr>
<td>
http://jsfiddle.net/ajthomascouk/WtLek/