gpt4 book ai didi

javascript - 三层 Accordion - 单击第一层即可展开第三层

转载 作者:行者123 更新时间:2023-12-03 06:39:06 25 4
gpt4 key购买 nike

我创建了一个 3 级 Accordion 。它几乎工作正常......但如果第三级折叠并且我尝试展开(?)第一级,我的第二级项目将变得不可见,而我的第三级项目仍然可见

代码如下:

<table class="table table-condensed" style="border-collapse:collapse;">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Description</th>
<th>Credit</th>
<th>Debit</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
<tr data-toggle="collapse" data-target="#demo1" class="accordion-toggle">
<td>1</td>
<td>05 May 2013</td>
<td>Credit Account</td>
<td class="text-success">$150.00</td>
<td class="text-error"></td>
<td class="text-success">$150.00</td>
</tr>
<tr data-toggle="collapse" data-target="#demo11" class="accordion-toggle">
<td colspan="6" class="hiddenRow"><div class="accordian-body collapse" id="demo1"> Demo1 </div> </td>
</tr>
<tr>
<td colspan="6" class="hiddenRow"><div class="accordian-body collapse" id="demo11"> Demo11 </div> </td>
</tr>
<tr data-toggle="collapse" data-target="#demo2" class="accordion-toggle">
<td>2</td>
<td>05 May 2013</td>
<td>Credit Account</td>
<td class="text-success">$11.00</td>
<td class="text-error"></td>
<td class="text-success">$161.00</td>
</tr>
<tr data-toggle="collapse" data-target="#demo21" class="accordion-toggle">
<td colspan="6" class="hiddenRow"><div id="demo2" class="accordian-body collapse">Demo2</div></td>
</tr>
<tr>
<td colspan="6" class="hiddenRow"><div class="accordian-body collapse" id="demo21"> Demo21 </div> </td>
</tr>

</tbody>

JSFiddle Example

如果有人有想法,那就太好了。

谢谢:)

最佳答案

因为你的 data-target="#demo1"是指向的,所以当你点击目标时,它会检查 demo1 id,但第二个选项在 div 之外,所以它不会关闭 div,所以你必须更改结构你必须在 demo1 id 中移动 3 层。

  <tr data-toggle="collapse" data-target="#demo11" class="accordion-toggle">
<td colspan="6" class="hiddenRow"><div class="accordian-body collapse" id="demo1"> Demo1 </div> </td>
</tr>
<tr>
<td colspan="6" class="hiddenRow"><div class="accordian-body collapse" id="demo11"> Demo11 </div> </td>
</tr>

更改为

<tr data-toggle="collapse" data-target="#demo11" class="accordion-toggle">
<td colspan="6" class="hiddenRow"><div class="accordian-body collapse" id="demo1"> Demo1
<div>
<div colspan="6" class="hiddenRow"><div class="accordian-body collapse" id="demo11"> Demo11 tytjtyty</div> </div>
</div>
</div> </td>
</tr>

供引用https://plnkr.co/edit/S39oZfRWuWf4YiKFRCRE?p=preview

关于javascript - 三层 Accordion - 单击第一层即可展开第三层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38050884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com