[英]Use css to style instead of jQuery
我遇到了以下代碼:
$("#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;
}
#TABLE_ID tr:nth-child(odd) {YOUR RULE HERE}
#customTable tr:nth-child(even) {background: #CCC}
#customTable tr:nth-child(odd) {background: #FFF}
#customTable tr:nth-child(even) {background: color;}
#customTable tr:nth-child(odd) {background: color;}
此鏈接可能對您有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.