jquery - Bootstrap nav menu. Close it on click to any of its item -
i using following html code:
<nav class="navbar navbar-default"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mynavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="collapse navbar-collapse" id="mynavbar"> <ul class="nav navbar-nav list-inline"> <li> <a href="#" v-on:click.prevent="showhomepage"> <span class="btn btn-default btn-sm">home</span> </a> </li> <!-- other items ..... --> </ul> </div> </nav>
how can make menu items closed when li items clicked on small screen?
you jquery easily:
jquery("document").ready(function(){ if (jquery(".navbar-toggle").is(":visible")) { //check if menu button visible jquery(".nav-menu li").click(function() { jquery(".navbar-toggle").trigger("click") // emulate click on menu button close menu }) } })
Comments
Post a Comment