手风琴折叠 jquery
我正在使用手风琴插件,当用户单击页面上不是手风琴的任何位置时,我希望手风琴折叠任何打开的列表。
我下面的代码的工作原理是折叠手风琴,但当我单击它时它仍然折叠它。
我正在寻找(我认为)是一个选择器,它将选择所有内容,然后删除诸如 #accordion 之类的内容以及与手风琴相关的任何 li。
$('html').not('#accordion, li').click(function(){
collapseAll();
});
I am using the accordion plugin, and when a user click anywhere on the page that is not the accordion I want the accordion to collapse any open lists.
The code I have below works in the sense that it collapses the accordion, but it still collapses it wheni click on it.
What I am lookin for (i think), is a selector that will select everything, and then remove things like #accordion, and any li's that are related to the accordion.
$('html').not('#accordion, li').click(function(){
collapseAll();
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
html
选择器在这里是错误的。您想要除 #according 之外的所有项目。这将是html
selector is wrong here. You want all items but #according. And this will be已解决
当用户在 DIV 外部单击时,使用 jQuery 隐藏 DIV
以防万一有人偶然发现这个问题,我在这里找到了答案^^
SOLVED
Use jQuery to hide a DIV when the user clicks outside of it
Just incase anyone stumbles across this question, i found my answer here ^^