Reputation: 1
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?
Upvotes: 0
Views: 569
Reputation: 723548
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');
Upvotes: 2
Reputation: 9031
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/
Upvotes: 0