我尝试使用交替重复的三色行的 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*/
关于javascript - 具有三色行的 Jquery 数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28603179/