文本未隐藏在 table 中

text not hidden within table

我对以下 html 标记感到很困惑

<table id="tableCharts" hidden=true>
  <tr>
    <table id="tableResetLinks">
      <tr>
        <td>
          <a href="test"><b>Reset All</b></a>
        </td>
      </tr>
    </table>
  </tr>
  <tr>
    <td id="chart-pie-pnlperstrategy">
      <div class="chart-title">PnL by Strategy</div>
    </td>
  </tr>
</table>

我希望 hidden=true 样式元素适用于整个 tableCharts table 但它不会像文本 PnL by Strategy 那样显示hidden参数设置为。

hidden=true 确实适用于 tableResetLinks table。

上面的代码是我实际代码的简化。我确实需要 child table。

一定是我遗漏了什么。

尝试:

<table id="tableCharts" style="visibility:hidden">

<table id="tableCharts" style="display:none">

https://www.sitepoint.com/five-ways-to-hide-elements-in-css/

既然你需要 child table,你能做的就是使用包装器 (如 <div> 来包装整个 table,然后将 hidden 放在那里

<div hidden>
<table id="tableCharts">
  <tr>
    <table id="tableResetLinks">
      <tr>
        <td>
          <a href="test"><b>Reset All</b></a>
        </td>
      </tr>
    </table>
  </tr>
  <tr>
    <td id="chart-pie-pnlperstrategy">
      <div class="chart-title">PnL by Strategy</div>
    </td>
  </tr>
</table>
</div>