0

我遇到过这段代码:

$("#customTable tr:nth-child(odd)").addClass("newColour");

这会为表格的每个奇数行着色。

如何在 css 中处理而不是使用 jQuery 来执行它?

4

3 回答 3

1
#customTable tr:nth-child(odd) { 
    background-color:#eee; 
}
#customTable tr:nth-child(even) { 
    background-color:#fff; 
}

jsFiddle 示例

于 2012-08-01T15:29:11.157 回答
0
#TABLE_ID tr:nth-child(odd) {YOUR RULE HERE}
于 2012-08-01T15:30:27.853 回答
-1
 #customTable  tr:nth-child(even) {background: color;}
   #customTable tr:nth-child(odd) {background: color;}

此链接可能对您有所帮助

http://www.w3.org/Style/Examples/007/evenodd.en.html

于 2012-08-01T15:30:19.277 回答