jQuery multiple pseudo class
I'd like to make the zebra effect on the first column of a table. How could I could select the first td of 开发者_开发技巧a tr and apply nth-child(2n) on it?
The :nth-child()
pseudo-class goes to the tr
, and the :first-child
pseudo-class to the td
:
$('tr:nth-child(2n) td:first-child').css('background-color', '#ccc');
You need to add nth-child(2n)
to the <tr>
and then use :first-child
to only select the first <td>
. Check it out here:
http://jsfiddle.net/ajthomascouk/WtLek/
精彩评论