开发者

$('tr:even').addClass('alt');

why does $('tr:even').addClass('a开发者_Go百科lt'); select from the 1st row and $('tr:nth-child(even)').addClass('alt'); selects from the 2nd row ?


It's because :even gets even elements using 0-based indexing and :nth-child() uses 1-based indexing.


maybe the selector looks at the index and nth-child(even) looks at the length? Seems like an oversight.


got it! :odd and :even selectors use Javascript native zero based numbering. so the first row counts as 0(even)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜