我想循环遍历表格的行并检查它们的背景颜色.这是我到目前为止:
var TheColor = "";
$('#MyTable tr').each(function () {
TheColor = "";
TheColor = $(this).attr('background-color');
alert(TheColor);
});
Run Code Online (Sandbox Code Playgroud)
当循环展开时,我所得到的只是"未定义"而我看不出原因.但是,当我写TheColor = $(this).html(); 我得到了预期的输出.
谢谢你的建议.
您需要选择它:
$(this).css('background-color');
Run Code Online (Sandbox Code Playgroud)
由于您要查找的属性实际上是样式属性(style="background-color: red").
| 归档时间: |
|
| 查看次数: |
2698 次 |
| 最近记录: |