Keep Bootstrap dropdown open on click

后端 未结 7 1017
我寻月下人不归
我寻月下人不归 2020-12-08 01:54

I use a bootstrap dropdown as a shoppingcart. In the shopping cart is a \'remove product\' button (a link). If I click it, my shoppingcart script removes the product, but th

7条回答
  •  无人及你
    2020-12-08 02:23

    The menu opens when you give show class to the menu, so you can implement the function yourself without using data-toggle="dropdown".

    
    
    #overlay{
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      z-index: 1000;
      display: none;
    }
    
    #overlay.show{
      display: block;
    }
    
    .dropdown-menu{
      z-index: 1001;
    }
    
    $('button, #overlay').on('click', function(){
      $('.dropdown-menu, #overlay').toggleClass('show')
    })
    

    Try this in codepen.

提交回复
热议问题