开发者

jQuery multiple pseudo class

开发者 https://www.devze.com 2023-03-26 03:27 出处:网络
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

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

精彩评论

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