Bootstrap 3 Hide Dropdown Menu on Menu Item Click

后端 未结 6 1066
眼角桃花
眼角桃花 2021-02-04 07:05

Check out the fiddle. I have a basic Bootstrap 3 responsive nav like so:

    
&
6条回答
  •  隐瞒了意图╮
    2021-02-04 07:46

    Change this:

    $(document).ready(function () {
        $("#navbar li a").click(function(event) {
            // check if window is small enough so dropdown is created
            $("#navbar-toggle").is(":visible")
                $("#nav-collapse").toggle();
        });
      });
    

    to this:

    $(document).ready(function () {
        $("#navbar li a").click(function(event) {
            // check if window is small enough so dropdown is created
        $("#nav-collapse").removeClass("in").addClass("collapse");
        });
    });
    

    See http://jsfiddle.net/fw7vh/4/

提交回复
热议问题