Ajax 如何在表中为tr id创建逻辑/查找样式
我有一个定义如下的表格:Ajax 如何在表中为tr id创建逻辑/查找样式,ajax,Ajax,我有一个定义如下的表格: <table id="DateTable" width="100%"> <tbody> <tr id="prior" style="display: none;" ><td> . .. .. . prior </td></tr> <tr id="current"><td> . .. .. curren
<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>
我哪里出错了?您需要使用以下方法:
还要注意,ID在DOM中应该是唯一的,并且您忘记在之前的元素的选择器中添加#
符号
因此,您的代码可以很简单:
if($("#prior").css("display") === "none") {
alert("Style exists!!");
} else {
alert("Style doesn't exist.");
}
if($("#DateTable tr").find("#prior").css("display") === 'none')
if($("#prior").css("display") === "none") {
alert("Style exists!!");
} else {
alert("Style doesn't exist.");
}