我正在尝试使用javascript切换具有标签和文本框的div元素的显示。
这是代码片段
<table id="authenticationSetting" style="display: none">
<div id="authenticationOuterIdentityBlock" style="display: none;">
<tr>
<td class="orionSummaryHeader"><orion:message key="policy.wifi.enterprise.authentication.outeridentitity"/>: </td>
<td class="orionSummaryColumn">
<orion:textbox id="authenticationOuterIdentity" size="30"/>
</td>
</tr>
</div>
</table>
但是,在页面加载时div元素仍然显示,切换table元素的显示工作正常。
我不知道为什么它不起作用,可能是table元素的样式覆盖了div元素的样式。
附言我仍然能够在div中隐藏元素,但不能隐藏div本身。
最佳答案
只需将<div>
更改为<tbody>
<table id="authenticationSetting" style="display: none">
<tbody id="authenticationOuterIdentityBlock" style="display: none;">
<tr>
<td class="orionSummaryHeader">
<orion:message key="policy.wifi.enterprise.authentication.outeridentitity" />:</td>
<td class="orionSummaryColumn">
<orion:textbox id="authenticationOuterIdentity" size="30" />
</td>
</tr>
</tbody>
</table>
关于html - 表内的<div样式显示=“none”>不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17461411/