引导程序可折叠选项禁用

时间:2020-07-23 11:29:53

标签: javascript bootstrap-4

请检查以下示例。当单击弹出按钮时,可折叠功能不起作用。如何停止。 html

    <div class="panel panel-info">
  <div class="panel-heading collapsed" data-toggle="collapse" data-target="#bar">
    <i class="fa fa-fw fa-chevron-down"></i>
    <i class="fa fa-fw fa-chevron-right"></i>Foo
        <button>
      Popup button
      </button>
  </div>
  <div class="panel-body">
    <!-- The inside div eliminates the 'jumping' animation. -->
    <div class="collapse" id="bar">
      Bar.
  
    </div>
  </div>
</div>

working sample

1 个答案:

答案 0 :(得分:0)

您必须在click函数中监听事件并添加stopPropagation

$(".popup").click(function(e) {
  alert("fasfsa");
  e.stopPropagation();  
});

https://jsfiddle.net/pLho9q26/1/