使用css而不是jQuery创建样式
我遇到了以下代码:使用css而不是jQuery创建样式,jquery,css,Jquery,Css,我遇到了以下代码: $("#customTable tr:nth-child(odd)").addClass("newColour"); 这把桌子的每一排都涂上了颜色 如何在css中处理这个问题,而不是使用jQuery来执行它 #customTable tr:nth-child(odd) { background-color:#eee; } #customTable tr:nth-child(even) { background-color:#fff; } 此链接可
$("#customTable tr:nth-child(odd)").addClass("newColour");
这把桌子的每一排都涂上了颜色
如何在css中处理这个问题,而不是使用jQuery来执行它
#customTable tr:nth-child(odd) {
background-color:#eee;
}
#customTable tr:nth-child(even) {
background-color:#fff;
}
此链接可能对您有所帮助
与另一个答案中的注释相同,选择器不完整。@t检查问题可能不同,但答案只能是一个。@j08691:当您的答案仍然不完整时,您收到了否决票。这就是否决票的原因。@prash:请澄清“问题可能不同,但答案应该只有一个。”。什么答案?问题很清楚,这个答案不完整,现在应该足够了。对不起,我以为你因为同样的答案而失望了。
#customTable tr:nth-child(even) {background: color;}
#customTable tr:nth-child(odd) {background: color;}
#TABLE_ID tr:nth-child(odd) {YOUR RULE HERE}