Bootstrap嵌套折叠仅包含父级折叠事件

我有一个嵌套的Bootstrap Collapse,在父和子折叠上都显示了一个事件。 我需要它只对父崩溃而不是对孩子开火。

$(document).ready(function() { $("#accordion2").on("shown",function() { alert("shown!"); }); }); 

这是一个例子: http : //jsfiddle.net/xb9K6/

您可以使用event对象的stopPropagation方法。

 $(".accordion").on("shown",function(event) { event.stopPropagation(); }); 

http://jsfiddle.net/SPZZv/