Close Bootstrap Dropdown after link click



  • 3 Answer(s)

      Provide a class to the  links (e.g. download):

    <a href="#" class="download" data-bind="disable: noResults()....
    

      Make the dropdown an id (e.g. dlDropDown):

    <button class="btn dropdown-toggle" id="dlDropDown" data-toggle="dropdown" data-bind="enable: !noResults()">
    

      Finally include a event handler:

    $("a.download").click(function()
    {
      $("#dlDropDown").dropdown("toggle");
    });
    
    Answered on November 17, 2018.
    Add Comment

    It work finely with old bootstrap markup without any class or id. But it help to provide a solution in without changing anything old.

    $(".dropdown-menu a").click(function()
    {
      $(this).closest(".dropdown-menu").prev().dropdown("toggle");
    });
    
    Answered on November 17, 2018.
    Add Comment

    This code reduce the dropdowns and increase navmenus on the page

    $('.in,.open').removeClass('in open');
    
    Answered on November 17, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.