手风琴折叠 jquery

发布于 2024-11-18 20:05:28 字数 286 浏览 1 评论 0原文

我正在使用手风琴插件,当用户单击页面上不是手风琴的任何位置时,我希望手风琴折叠任何打开的列表。

我下面的代码的工作原理是折叠手风琴,但当我单击它时它仍然折叠它。

我正在寻找(我认为)是一个选择器,它将选择所有内容,然后删除诸如 #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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滥情哥ㄟ 2024-11-25 20:05:28

html 选择器在这里是错误的。您想要除 #according 之外的所有项目。这将是

$('*').not('#accordion, li').click(function(){

        collapseAll();              
});

html selector is wrong here. You want all items but #according. And this will be

$('*').not('#accordion, li').click(function(){

        collapseAll();              
});
萌酱 2024-11-25 20:05:28

已解决

当用户在 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 ^^

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文