How do I prevent my dropdown from closing when clicking inside it?

前端 未结 1 1955
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-19 13:55

I\'m using Bootstrap to create a dropdown for my website, but I am having some problems with it.

On my website, if clicked on \"Select Populations\" the popup will a

相关标签:
1条回答
  • 2020-12-19 14:47

    '.dropdown-menu' catches the the bubble. There is no need to catch elements inside of the dropdown in this case.

    e.stopPropagation() prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.

    $('.dropdown-menu').on('click', function(e) {
      e.stopPropagation();
    });
    
    0 讨论(0)
提交回复
热议问题