Javascript将行颜色更改回原始颜色
我想知道如何拥有这段代码的功能,但当我取消选中代码时,它会重置回原来的背景色。在下面的脚本中,它会变回白色,如您所见。我使用的行通过php在foreach循环中设置类(背景色),具体取决于数组中的内容。我只见过下面这样的例子,如果选中,它会设置颜色,否则Javascript将行颜色更改回原始颜色,javascript,html,css,Javascript,Html,Css,我想知道如何拥有这段代码的功能,但当我取消选中代码时,它会重置回原来的背景色。在下面的脚本中,它会变回白色,如您所见。我使用的行通过php在foreach循环中设置类(背景色),具体取决于数组中的内容。我只见过下面这样的例子,如果选中,它会设置颜色,否则 $(document).ready(function() { $('input:checkbox:not(#checkall)').live('click', function(event) { if ($("#chec
$(document).ready(function() {
$('input:checkbox:not(#checkall)').live('click', function(event) {
if ($("#checkall").attr('checked') == true && this.checked == false) {
$("#checkall").attr('checked', false);
$(this).closest('tr').css("background-color", "#ffffff");
}
if (this.checked == true) {
$(this).closest('tr').css("background-color", "#ffffcc");
CheckSelectAll();
}
if (this.checked == false) {
$(this).closest('tr').css("background-color", "#ffffff");
}
});
});
任何帮助都将不胜感激,我一点也不擅长JS
谢谢。像这样:
$(this).closest('tr').css("background-color", "");