首页 > 解决方案 > 隐藏样式显示:无不起作用

问题描述

我想隐藏<tr>,当我在下面为<td>它工作但<tr>它没有时,我怎么能隐藏<tr>

<td style="display:none">Eve</td> -- works

<tr style='display:none'>
                    <%# DataBinder.Eval(Container.DataItem, "HighlightedTextSearch")%>
                         </tr> -- does not work

标签: html

解决方案


display:none在表格行上工作正常:

<table>
  <tr style="display:none">
    <td>This will not be visible</td>
  </tr>
</table>

您的问题是您没有将内容包装在 a 中<td>,因此它完全被撞到了桌子外面,因此不受tr's 样式的控制:

table {border: 1px solid}
<table>
<tr style="display:none">
This is invalid HTML, because it's not inside a table cell.
Note that this sentence is displayed *before* the table rather than inside it.
</tr>
</table>


推荐阅读