jQuery 手风琴在加载时关闭
如何在页面加载时关闭手风琴小部件?这是我正在使用的代码:
//Accordion
$( ".accordion" ).accordion({
autoHeight: false,
navigation: true,
collapsible: true,
active: false
});
另外,它可能不重要,但手风琴 div 位于对话框 div 内。
How can I get the accordion widget to be closed when the page loads? This is the code I'm using:
//Accordion
$( ".accordion" ).accordion({
autoHeight: false,
navigation: true,
collapsible: true,
active: false
});
Also, it may be unimportant but the accordion divs are inside dialog divs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
active
选项设置为false
应该(根据 docs)导致菜单在页面加载时折叠(尽管它特别要求collapsible: true
(您已经拥有)。如果这尚未位于
$(window).load()
或$(document).ready()
中,则需要将其包装在其中之一中;它被如此包装然后没有演示(也许JS Fiddle,或JS Bin?)很难表明可能发生的情况或出现的问题。JavaScript的其余部分(除了调用
.accordion()
正在执行吗?如果没有,可能会在某个地方出现 JS 错误。可能值得通过 JS Lint 运行它。 可以肯定。The
active
option being set tofalse
should (according to the docs) cause the menu to be collapsed on page-load (though it specifically requirescollapsible: true
(which you already have).If this isn't already in a
$(window).load()
or$(document).ready()
then it needs to be wrapped in one of those; if it is so wrapped then without a demo (perhaps JS Fiddle, or JS Bin?) it's difficult to suggest what might be happening, or going wrong.Is the remainder of the JavaScript (beyond the call to
.accordion()
being executed? If not there might be a JS error, somewhere. It might be worth running it through JS Lint to be sure.索引值可以是布尔值或整数
请记住从小于 0 的索引开始
仅供参考,隐藏字段用于在回发之间保持打开的手风琴
The index value can be boolean or integer
Remember to start with index less than 0
FYI, the hidden field is to keep save the accordions open between postbacks