Bootstrap dropdown a标签或者button 点击事件

$(function() { $("ul.dropdown-menu").on("click", "[data-stopPropagation]", function(e) {
   ////
[data-stopPropagation]为选择器,li里面点击事件选择器
   e.stopPropagation(); 
});
});


定义属性值data-stopPropagation的元素点击时停止传播事件

 

 

 class="dropdown-menu"> 
  • <-- Do not close when clicking this link --> href="#" data-stopPropagation="true"> ...
  • <-- Do not close when clicking this checkbox --> type="checkbox" data-stopPropagation="true" ... >
  • <-- Do not close when clicking anything in this LI --> data-stopPropagation="true"> ...
    之后需要时加上该属性即可。

    转载于:https://www.cnblogs.com/chenkg/p/3873486.html

    你可能感兴趣的:(Bootstrap dropdown a标签或者button 点击事件)