gpt4 book ai didi

javascript - 具有三色行的 Jquery 数据表

转载 作者:太空狗 更新时间:2023-10-29 15:49:39 24 4
gpt4 key购买 nike

我尝试使用交替重复的三色行的 jquery 数据表。但我只有两个彩色行重复。

Tried jquery datatable with tri colored rows
我正在使用偶数/奇数属性进行着色

$(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*/

check this Demo in js fiddle

关于javascript - 具有三色行的 Jquery 数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28603179/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com