簡體   English   中英

具有三色行的Jquery數據表

[英]Jquery datatable with tri color rows

我嘗試了三色行的jquery數據表,它重復交替。但我只有兩個彩色的行重復。

嘗試使用三色行的jquery數據表
我正在使用屬性偶數/奇數來着色

$(document).ready(function() {
    $('#example').dataTable();
} );
$(document).ready(function() {
 $("#example tr:even").css("background-color", "LightYellow");
 $("#example tr:odd").css("background-color", "LightBlue");
});

您不必使用jquery來實現此CSS非常適合該作業。 試試這個。

/*tri color rows*/
table.dataTable tbody tr:nth-child(3n+1)  {background-color: #FFCCCC;}
table.dataTable tbody tr:nth-child(3n+2)  {background-color: #99D6AD;}

table.dataTable tbody tr:nth-child(3n)    {background-color: #EBD6FF;}
th {
background: #aaf;
}
thead{
    background: #aaf;
}
/* End: tri color rows*/

在js小提琴中查看此演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM