jQuery第n个孩子

问题描述:

是否有可能让jQuery做与nth:child(odd)相同的工作?jQuery第n个孩子

这样我就可以在IE6等浏览器中的表中添加斑马线了?

如果有人可以帮忙吗?

可以使用:odd选择器选择奇数表行,像这样:

$("tr:odd").css("background-color", "#DDD"); 

您使用了错误的语法:$(":nth-child(odd)")或更短$(":odd")

http://api.jquery.com/odd-selector/

http://api.jquery.com/nth-child-selector/

$("tr:nth-child(odd)").addClass("odd_row"); 

$('.class:nth-child(odd)')...; 

http://api.jquery.com/nth-child-selector/

只是做( “表TR:奇”)或( “表TR:连”)。尝试使用http://api.jquery.com,这些类型的问题大部分都会被回答。