【发布时间】:2013-08-22 09:38:49
【问题描述】:
我想根据<tr> 中<td> 的背景颜色隐藏<tr>,我当前的代码根据<td> 中的文本隐藏<tr>,但那是不是一个很好的解决方案。该表是一个日历,因此如果 JQuery 可以根据背景颜色隐藏表行,那就太好了。
我当前的代码:
function ShowAbsence()
{
if(!presenceActive) clearPresence();
$('table#newspaper-a tr:not(#header, #trWeekNummer)').each(function() {
var toggle1 = true;
$('td:not(#firstlastname)',this).each(function() {
if($(this).text() == "f" || $(this).text() == "M" || $(this).text() == "A") {
toggle1 = false;
}
});
if(toggle1) {
$(this).toggle();
}
});
if(absenceActive) {
absenceActive = false;
} else {
absenceActive = true;
}
}
这很好用,但正如您所见,它会根据单元格中的文本隐藏。希望您能帮我根据背景颜色隐藏它!
【问题讨论】:
-
使用:
$(this).css('background-color') -
if($(this).css('background-color') == "#088A08" || $(this).css('background-color') == "#088A08" || $(this).css('background-color') == "#D7DF01") 不幸的是不起作用
-
@ArvindBhardwaj 会返回一个 RGB 值,这通常是不可取的。
标签: jquery html-table