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

标签 javascript jquery html css

我尝试使用交替重复的三色行的 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/

相关文章:

javascript - function.call() 或 click()

javascript按键多条记录问题

javascript - 使用 jquery 隐藏和取消隐藏搜索 div

javascript - div 底部带有消息的聊天系统

javascript - Angular - 将 ng Strict 与 Google Chart 库一起使用

javascript - jQuery when() 函数 : does it fire before each single done?

javascript - 如何在 html 工具提示中转义 html

javascript - 为什么我要获取的URL参数显示不全?

javascript - token "in"存在语法错误,需要标识符

javascript - quill.formatText() 不允许嵌套格式