Bootstrap嵌套折叠,仅在父折叠上具有事件 [英] Bootstrap Nested Collapse With Events Only On Parent Collapse
本文介绍了Bootstrap嵌套折叠,仅在父折叠上具有事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个嵌套的Bootstrap Collapse,其中显示了父级和子级Collapse上显示的事件.我需要它仅对父母崩溃而不对孩子开枪.
I have a nested Bootstrap Collapse with a shown event firing on both the parent and the child Collapse. I need it to only fire on the parent Collapse and not on the child.
$(document).ready(function() {
$("#accordion2").on("shown",function() {
alert("shown!");
});
});
这里是一个示例: http://jsfiddle.net/xb9K6/
推荐答案
您可以使用event
对象的stopPropagation
方法.
You can use stopPropagation
method of the event
object.
$(".accordion").on("shown",function(event) {
event.stopPropagation();
});
这篇关于Bootstrap嵌套折叠,仅在父折叠上具有事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文