我也可以通过单击其他元素来展开/折叠 JQuery ui Accordion 的内容吗?
默认情况下,有内容标题来控制展开/折叠。但在我的情况下,我也可以通过其他元素展开/折叠内容。例如:
jquery ui accodion代码的基本结构:
<script>
$(function() {
$( "#accordion" ).accordion();
});
</script>
<div class="demo">
<div id="accordion">
<h3><a href="#">Section 1</a></h3>
<div>
<p>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
</p>
</div>
......
</div>
和现在。我还有另一个要素,就像:
<ul id="another elements can expand/collapse too">
<li><a href=""> expand/collapse contents of section1 of id=accordion too</a></li>
........
</ul>
非常感谢!
By default, there are headers of contents to control expand/collapse.But in my situation,I could expand/collapse the contents by another elements ,too. For example:
the basic structure of jquery ui accodion code:
<script>
$(function() {
$( "#accordion" ).accordion();
});
</script>
<div class="demo">
<div id="accordion">
<h3><a href="#">Section 1</a></h3>
<div>
<p>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
</p>
</div>
......
</div>
and now. I have another elements,just like :
<ul id="another elements can expand/collapse too">
<li><a href=""> expand/collapse contents of section1 of id=accordion too</a></li>
........
</ul>
thank you very much!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
更新 JQuery UI 后,手风琴上没有“活动”方法。因此,要折叠所有手风琴,请使用:
After update of JQuery UI there is no "active" method on accordion. So, to collapse all accordions use:
折叠手风琴选项卡:
展开第一个手风琴选项卡:
Collapse accordion tab:
Expand first accordion tab:
您可以使用 .activate 并传入 false 来以编程方式折叠所有元素。由于您一次只能打开一个元素,因此这将折叠显示该链接的任何打开的元素。仅当您将
collapsible
设置为true
时,此功能才有效。您可以传入要展开的其他元素,以便在单击时展开该元素。
You can use .activate with false passed in to collapse all elements programmatically. Since you only ever have one element open at a time, this will work to collapse whatever element is open showing that link. This will only work if you have
collapsible
set totrue
.You can pass in what other element you want to expand to expand that element on click.
我在手风琴最初加载后折叠/展开时遇到了麻烦。为了解决这个问题,我使用了:
...它模仿单击标题区域并强制切换激活类。
感觉就像是黑客攻击,但它确实有效,贝斯特。
I to had trouble getting the Accordions to collapse/expand after they were initially loaded. To get around this I used:
...which mimics clicking the header area and will force toggle the activation classes.
Felt like a hack, but it's what worked, Best.
使用 Bootstrap:
那么你可以使用以下方法折叠:
Using Bootstrap:
then you could collapse using: