gpt4 book ai didi

jquery - 刷新时获取数组中所有打开的面板

转载 作者:太空宇宙 更新时间:2023-11-04 08:42:22 25 4
gpt4 key购买 nike

我正在使用 Bootstrap Collapse 实现一个可折叠面板,如下所示 fiddle经过一些修改。

<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" href="#collapseOne">
Collapsible Group Item #1
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse">
<div class="panel-body">
Body1
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" href="#collapseTwo">
Collapsible Group Item #2
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
Body 2
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" href="#collapseThree">
Collapsible Group Item #3
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body">
Body 3
</div>
</div>
</div>
</div>


.panel-heading .accordion-toggle:after {
/* symbol for "opening" panels */
font-family: 'Glyphicons Halflings'; /* essential for enabling glyphicon */
content: "\e114"; /* adjust as needed, taken from bootstrap.css */
float: right; /* adjust as needed */
color: grey; /* adjust as needed */
}
.panel-heading .accordion-toggle.collapsed:after {
/* symbol for "collapsed" panels */
content: "\e080"; /* adjust as needed, taken from bootstrap.css */
}

我还让页面每 60 秒重新加载一次。默认情况下,我所有的页面加载面板都是关闭的。我需要存储所有打开的面板,然后在刷新后将其放回打开状态。此代码将为我提供所有选项卡,而不仅仅是打开的选项卡。

myArray = $('.accordion-toggle');

如何把所有打开的面板都放到一个数组中,然后让它们在页面刷新后打开?如果我得到所有打开的面板,我可以从中删除折叠的类。编辑 1:

headerArray = $('.accordion-toggle').find('a[aria-expanded=true]').closest('div');

这只给我第一个 div,而不是页面中的所有 div。

最佳答案

正如我所见,[aria-expanded] 属性在折叠或展开时发生变化,所以我刚刚找到 [area-expanded] 打开的 anchor 标记列表,并找到要存储在数组中的面板的最近 div。

myArray = $('#accordion').find('a[aria-expanded=true]').closest('div')

关于jquery - 刷新时获取数组中所有打开的面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44029388/

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