[英]Alternate table row background-color, restarting with every tbody
I can add a background to alternating rows in a table like this: 我可以为表中的交替行添加背景,如下所示:
$(".myTbl tr:even td").css("background-color", "#f5f5f5");
However, if I have multiple instances of withing the same table I would like it to restart with each set. 但是,如果我有多个使用同一个表的实例,则希望每个表都重新启动。 for some reason the following code did not work:
由于某些原因,以下代码无法正常工作:
$("tbody tr:even td").css("background-color", "#f5f5f5");
PS Using jQuery to appease older IE browsers... PS使用jQuery来安抚较旧的IE浏览器...
Here, use this 在这里用这个
$(document).ready(function()
{
$("table tbody tr:even").css("background-color", "#F4F4F8");
$("table tbody tr:odd").css("background-color", "#EFF1F1");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.