我的表格定义如下:
<table id="DateTable" width="100%">
<tbody>
<tr id="prior" style="display: none;" ><td>
. .. .. . prior
</td></tr>
<tr id="current"><td>
. .. .. current
</td></tr>
</tbody>
</table>
我需要有逻辑确定风格=&#34; display:none;&#34;存在于&#34;先前&#34;标识。
我有这个,但它不起作用:
if($("#DateTable tr").find("prior").html("style=display: none;").length > 1)
alert("Style exists!!");
}
else {
alert("Style doesn't exist.");
}
我哪里错了?
答案 0 :(得分:0)
您需要使用css
方法:
if($("#DateTable tr").find("#prior").css("display") === 'none')
另请注意,ID在DOM中应该是唯一的,并且您忘记在#
元素的选择器中添加prior
符号。
所以你的代码很简单:
if($("#prior").css("display") === "none") {
alert("Style exists!!");
} else {
alert("Style doesn't exist.");
}