Stop just one dropdown toggle from closing on click

前端 未结 7 2215
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 08:58

I have a button dropdown (just one, not all of them), and inside of it, I want to have several input field where people can type stuff inside without the dropdown hiding as

7条回答
  •  醉话见心
    2020-12-13 09:21

    The issue is that the boostrap dropdown jQuery plugin closes the dropped-menu when you click anywhere else. You can disable that behavior by capturing the click events on your dropdown-menu element and keeping it from reaching the click event listeners on the body element.

    Just add

    $('.dropdown-menu').click(function(event){
         event.stopPropagation();
     });​
    

    jsfiddle can be found here

提交回复
热议问题