javascript - Twitter Bootstrap nav collapse Hide on click -


when click on menu item menu not close. have checked imports of js , css , seemingly ok, there else need run menu?

<!-- fixed navbar --> <nav class="navbar  navbar-default  navbar-fixed-top">     <div class="container-fluid">         <div class="navbar-header">             <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">                 <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">                 <li class="active"><a href="#home" class="active scroll">home</a></li>                 <li><a href="#about" class="scroll">sobre</a></li>                 <li><a href="#services" class="scroll">serviços</a></li>                 <li><a href="#testimonials" class="scroll">opiniões</a></li>                 <li><a href="#gallery" class="scroll">gallery</a></li>                 <li><a href="#news" class="scroll">news</a></li>                 <li><a href="#contact" class="scroll">contact</a></li>             </ul>         </div>     </div> </nav> 

image

for me works...

$(document).ready(function(){    $('.navbar-collapse a').on('click', function(){              $('.navbar-toggle').click();    });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css" rel="stylesheet"/>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>  <nav class="navbar  navbar-default  navbar-fixed-top">      <div class="container-fluid">          <div class="navbar-header">              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">      <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">                  <li class="active"><a href="#home" class="active scroll">home</a></li>                  <li><a href="#about" class="scroll">sobre</a></li>                  <li><a href="#services" class="scroll">serviços</a></li>                  <li><a href="#testimonials" class="scroll">opiniões</a></li>                  <li><a href="#gallery" class="scroll">gallery</a></li>                  <li><a href="#news" class="scroll">news</a></li>                  <li><a href="#contact" class="scroll">contact</a></li>              </ul>          </div>      </div>  </nav>


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -