我正在使用 dataTable,我正在动态地将数据传递给表,我想更改前 4 行的行的背景颜色,并分别为下一组 4 行重复这些颜色,依此类推。
我尝试使用 :nth-child css 选择器,但我可以选择奇数行/偶数行或指定我想在下面制作的行号
$("tr:nth-child(1)").css("background-color", "orange");
$("tr:nth-child(2)").css("background-color", "green");
$("tr:nth-child(3)").css("background-color", "blue");
$("tr:nth-child(4)").css("background-color", "yellow");
$("tr:nth-child(5)").css("background-color", "orange");
$("tr:nth-child(6)").css("background-color", "green");
$("tr:nth-child(7)").css("background-color", "blue");
$("tr:nth-child(8)").css("background-color", "yellow");