[英]Bootstrap accordion: collapse all except parent
I have multiples accordions in the same page. 我在同一页面上有多个手风琴。 Some of them inside another accordion.
其中一些在另一个手风琴内。
When one panel is clicked, I need to close all open panels. 单击一个面板后,我需要关闭所有打开的面板。 This is simple:
这很简单:
$('.panel-group').on('show.bs.collapse', function (event) {
$('.collapse.in').collapse('hide');
});
But I need to check if the panel is not parent of the clicked panel. 但是我需要检查面板是否不是所单击面板的父级。 How can I do this?
我怎样才能做到这一点?
An example of my issue: http://codepen.io/anon/pen/RRkBJw?editors=1010 我的问题的一个示例: http : //codepen.io/anon/pen/RRkBJw?editors=1010
Found a solution: 找到一个解决方案:
$('.panel-group').on('show.bs.collapse', function (event) {
var parent = $(event.target).parents('.collapse.in');
$('.collapse.in').not(parent).collapse('hide');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.