开发者

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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜