Bootstrap v2 Dropdown Navigation not working on Mobile Browsers

前端 未结 14 1112
遥遥无期
遥遥无期 2020-11-28 06:22

I am having an issue with the Bootstrap menu dropdowns on mobile devices (Bootstrap 2). A similar question was asked here with dropdown buttons, however the answer for that

相关标签:
14条回答
  • 2020-11-28 07:02

    Found this fix for version 2.3.2:

    <script>
    jQuery(document).ready(function($)  {
    $("li.dropdown a").click(function(e){
        $(this).next('ul.dropdown-menu').css("display", "block");
        e.stopPropagation();
      });
    }); </script>     
    

    Worked on two separate nav systems I built.

    0 讨论(0)
  • 2020-11-28 07:03

    When you click on the dropdown, it adds the open class to your <li class="dropdown"> giving you: <li class="dropdown open">. When you click a link on the dropdown menu or the 'Menu item 2 (dropdown)', the open class is removed causing the dropmenu to fold up again.

    The below fiddle shows how to stop the click event from propagating, but may cause you issues else where. Also, I only prevented the propagation on item #1 in the dropdown. You can use jQuery to have this happen on all items of the dropdown.

    JS Fiddle: http://jsfiddle.net/yDjw8/2/

    0 讨论(0)
提交回复
热议问题