亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我怎樣才能折疊所有表格行

我怎樣才能折疊所有表格行

慕蓋茨4494581 2023-12-11 10:21:35
我在表內有表行,在每行內還有另一個嵌套表行,我的問題是我可以在嵌套表行中折疊和展開,但是當我嘗試在主表中展開時,只有第一行展開當我啟動程序時,其余部分默認展開,我該如何修復它。這是我的代碼tbody.collapse.in {  display: table-row-group;}.tigray {  background-color: darkcyan;}.zoba {  background-color: forestgreen;}<!-- Latest compiled and minified CSS --><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"><!-- jQuery library --><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><!-- Latest compiled JavaScript --><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script><table class="table table-bordered table-sm ">  <thead class="thead-dark">    <tr>      <th></th>      <th>head1</th>      <th>head2</th>    </tr>  </thead>  <tbody>    <tr class="clickable" data-toggle="collapse" data-target="#group-of-rows-1" aria-expanded="false" aria-controls="group-of-rows-1">      <td class="tigray">title1</td>      <td class="tigray">35</td>      <td class="tigray">35</td>    </tr>  </tbody>  <tbody id="group-of-rows-1" class="collapse">    <tr class="clickable" data-toggle="collapse" data-target="#group-of-rows-2" aria-expanded="false" aria-controls="group-of-rows-2">      <td class="zoba">nested 1</td>      <td class="zoba">29</td>      <td class="zoba">29</td>      <tbody id="group-of-rows-2" class="collapse">        <tr class="table-warning">          <td>nested title1</td>          <td>13</td>          <td>13</td>        </tr>        <tr class="table-warning">          <td>nested title2</td>          <td>18</td>          <td>13</td>        </tr>        <tr class="table-warning">          <td>nested title 3</td>          <td>32</td>          <td>13</td>        </tr>      </tbody>    </tr>
查看完整描述

1 回答

?
慕村9548890

TA貢獻1884條經驗 獲得超4個贊

您不能在另一個 tbody 中使用 tbody,?它不是合法的 HTML。

按照這個代碼?↓↓

<!-- Latest compiled and minified CSS -->

<link rel="stylesheet" >


<!-- jQuery library -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>


<!-- Latest compiled JavaScript -->

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>



<table class="table table-bordered table-sm ">

? <thead class="thead-dark">

? ? <tr>

? ? ? <th></th>

? ? ? <th>head1</th>

? ? ? <th>head2</th>

? ? </tr>

? </thead>

? <tbody>

? ? <tr class="clickable" data-toggle="collapse" data-target=".group-of-rows-1" aria-expanded="false" aria-controls="group-of-rows-1">

? ? ? <td class="tigray">title1</td>

? ? ? <td class="tigray">35</td>

? ? ? <td class="tigray">35</td>

? ? </tr>

? </tbody>


? <tbody id="" class="collapse group-of-rows-1">

? ? <tr class="clickable" data-toggle="collapse" data-target="#group-of-rows-2" aria-expanded="false" aria-controls="group-of-rows-2">

? ? ? <td class="zoba">nested 1</td>

? ? ? <td class="zoba">29</td>

? ? ? <td class="zoba">29</td>

? ? ??

? ? </tr>

? </tbody>


? <tbody id="group-of-rows-2" class="collapse">

? ? ? <tr class="table-warning">

? ? ? ? <td>nested title1</td>

? ? ? ? <td>13</td>

? ? ? ? <td>13</td>

? ? ? </tr>

? ? ? <tr class="table-warning">

? ? ? ? <td>nested title2</td>

? ? ? ? <td>18</td>

? ? ? ? <td>13</td>

? ? ? </tr>

? ? ? <tr class="table-warning">

? ? ? ? <td>nested title 3</td>

? ? ? ? <td>32</td>

? ? ? ? <td>13</td>

? ? ? </tr>

? ? </tbody>

? <tbody id="" class="collapse group-of-rows-1">

? ? <tr class="clickable" data-toggle="collapse" data-target="#group-of-rows-3" aria-expanded="false" aria-controls="group-of-rows-3">

? ? ? <td class="zoba">nested 2</td>

? ? ? <td class="zoba">29</td>

? ? ? <td class="zoba">29</td>

? ? ??

? ? </tr>

? ? </tbody>

? <tbody id="group-of-rows-3" class="collapse">

? ? ? <tr class="table-warning">

? ? ? ? <td>nested title4</td>

? ? ? ? <td>13</td>

? ? ? ? <td>13</td>

? ? ? </tr>

? ? ? <tr class="table-warning">

? ? ? ? <td>nested title5</td>

? ? ? ? <td>18</td>

? ? ? ? <td>13</td>

? ? ? </tr>

? ? ? <tr class="table-warning">

? ? ? ? <td>nested title 6</td>

? ? ? ? <td>32</td>

? ? ? ? <td>13</td>

? ? ? </tr>

? ? </tbody>

</table>

但是,您可以在單個 TABLE 元素中擁有多個 TBODY 元素,因此您可以執行以下操作:


<table>?

? <tbody>?

? ? <tr>?

? ? ? <td>...</td>?

? ? ? <td>...</td>?

? ? </tr>?

? </tbody>

? <tbody >?

? ? <tr>?

? ? ? <td>...</td>?

? ? ? <td>...</td>?

? ? </tr>?

? </tbody>

? <tbody>?

? ? <tr>?

? ? ? <td>...</td>?

? ? ? <td>...</td>?

? ? </tr>?

? </tbody>

</table>?


查看完整回答
反對 回復 2023-12-11
  • 1 回答
  • 0 關注
  • 128 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號