我正在寻找循环遍历表的行,并检查看看他们有什么颜色的背景。这是我到目前为止:循环遍历表行
var TheColor = "";
$('#MyTable tr').each(function() {
TheColor = "";
TheColor = $(this).attr('background-color');
alert(TheColor);
});
当循环展开,我得到的所有是“未定义”,我不明白为什么。但是,当我写TheColor = $(this).html();我得到了预期的产出。
感谢您的建议。
您的“tr”是否真的具有“背景色”属性?您可能应该查看具有该属性的样式属性。 – janhartmann 2011-03-21 18:42:56