jQuery 手风琴展开所有 div
当页面加载或事件发生时是否可以展开所有组件? 谢谢!!
Is it possible to expand all components when page is load or when an event occurs?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
只需使用这个
Simply use this
不,如果您指的是标签所示的手风琴。来自 jQuery。
http://docs.jquery.com/ UI/API/1.8/手风琴
No, if you are referring to accordion as your tag states. From jQuery.
http://docs.jquery.com/UI/API/1.8/Accordion
我推荐这个插件多开手风琴
I would recommend this plugin Multi-open Accordion
我喜欢这个切换框的实现:
http://jsfiddle.net/kevinPHPkevin/mZhTY/107/
发现这个在
我无法让 jQuery UI 手风琴选项卡在使用时更改颜色(如 a:visited),可以吗?
I like this implementation of a toggle box:
http://jsfiddle.net/kevinPHPkevin/mZhTY/107/
Found this at
I can't make a jQuery UI accordion tab change colors when used (like a:visited), can I?
哈哈,这里有很多答案,但最简单的解决方案似乎不是。答案是“是”和“不是”。你不能使用“传统”命令,但是你可以使用“类”并自己编写JS,即 超级简单!
只需使用 jQueryUI 的类和一点 JS 制作您自己的手风琴,就可以开始了。它非常简单,并且可以使用 jQueryUI ThemeRoller 进行维护。如果您想要“官方手风琴小部件”提供的“x-tra”选项,您可以使用更多的 CSS 或 JS 来管理所有这些选项。真的没那么难。下面是我将发布的代码的工作示例的链接。我所做的只是将他们的类逐字复制到我的 HTML 布局中。 HTML 的布局仍然像任何其他 jQueryUI 手风琴一样,只不过我们手动应用类而不是让 jQuery 来完成。看看下面就明白我的意思了。
或者当然你可以获取这个 xtra、jquery 主题就绪插件< /a>
jsFiddle
HTML
JavaScript
Lol, many answers on here, but the easiest solution doesn't seem to be. The answer is "yes" and "no". You can't use the "traditional" command, however you can use the "classes" and write the JS yourself, which is SUPER SIMPLE!
Just make your own Accordion using jQueryUI's classes and a little bit of JS and you're good to go. It's VERY easy and maintains with your jQueryUI ThemeRoller. If you want the "x-tra" options the "official accorrdion widget" provides, you can manage all of them with either a little more CSS or JS. Really Not that hard. Below is a link to the working example of the code I will post. All I simply did was copy their classes to my HTML layout verbatim. The HTML is still laid out just like any other jQueryUI accordion, except we apply the classes manually instead of letting jQuery do it. Look below to see what I mean.
Or of course you can get this xtra, jquery-theme ready plugin
jsFiddle
The HTML
The JavaScript
您可以在 jQuery 提供的
document.ready
事件中执行此操作,如下所示:CSS:
jQuery:
如果您的意思是使用 jQuery UI 中的手风琴控件,那么...您不应该使用手风琴,展开所有内容不是它的用途,他们建议不要这样做,因为它会导致其他问题。
You can do it in the
document.ready
event jQuery provides, like this:CSS:
jQuery:
If you mean with the accordion control from jQuery UI then...you shouldn't use accordion, expanding all isn't what it's for and they advise against this as it causes other issues.
为了使其不引人注目并且仅在访问者有 JavaScript 时隐藏,我将
CSS:
In
:
Bottom of
:
To make it unobtrusive and be hidden only if the visitor has javascript I'd put
CSS:
In
<head>
:Bottom of
<body>
:我知道我正在回答一个 2 年前的问题,但是没有任何解决方法或备用手风琴插件对我有用,所以我想出了一个极其简单的解决方法:只需单击“全部展开”链接即可销毁手风琴,然后单击“全部折叠”链接重新初始化它。像这样的事情:
展开全部和折叠所有链接将如下所示:
I know I'm answering a 2-year-old question, but none of the workarounds or alternate accordion plugins worked for me, so I came up with a devastatingly simple workaround: just destroy the accordion on click of an "expand all" link, and re-initialize it on click of a "collapse all" link. Something like this:
The expand all and collapse all links would look like this:
这个问题问出来已经有9年了。但我找到了以下解决方案来默认打开所有手风琴 div。这里我使用 slideDown() 方法来显示所有 div 内容。
It's been 9 years since this question was asked. But I found the below solution to open all the accordion divs by default. Here I used slideDown() method to show all the div contents.
我这样做了:
I did this:
我知道这确实太晚了,但我今天找到了解决方案。
只需使用
完整文章的链接
I know that is realy too late but i found the solution today.
Just simply use
link of full article
MultiAccordion jQuery UI 插件对我来说非常有用:
https://anasnakawa.wordpress.com/2011 /01/25/jquery-ui-multi-open-accordion/
在 jQuery UI 参考之后添加插件参考后,您只需要进行 2 个简单的更改:
$("#accordion_div").多手风琴(“选项”,“活动”,[0,1]);
MultiAccordion jQuery UI plugin worked great for me:
https://anasnakawa.wordpress.com/2011/01/25/jquery-ui-multi-open-accordion/
After adding the plugin reference after your jQuery UI reference, you just need to make 2 simple changes:
$("#accordion_div").multiAccordion("option", "active", [0,1]);