javascript - Bootstrap navbar wont collapse -


my bootstrap navbar got bootstrap jumbotron example won't collapse. if dont have right javascript, css or jquery links pls send me right ones. kinda new navbar thing need help. thank you! here code:

<nav class="navbar navbar-inverse navbar-static-top">   <div class="container">     <div class="navbar-header">       <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".nav-collapse" aria-expanded="false" aria-controls="navbar">         <span class="sr-only">toggle navigation</span>         <span class="icon-bar"></span>         <span class="icon-bar"></span>         <span class="icon-bar"></span>       </button>       <a class="navbar-brand" href="#">project name</a>     </div>     <div id="navbar" class="navbar-collapse collapse">       <ul class="nav navbar-nav">         <li class="active"><a href="#">home</a></li>         <li><a href="#about">about</a></li>         <li><a href="#contact">contact</a></li>         <li class="dropdown">           <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">dropdown <span class="caret"></span></a>           <ul class="dropdown-menu">             <li><a href="#">action</a></li>             <li><a href="#">another action</a></li>             <li><a href="#">something else here</a></li>             <li role="separator" class="divider"></li>             <li class="dropdown-header">nav header</li>             <li><a href="#">separated link</a></li>             <li><a href="#">one more separated link</a></li>           </ul>         </li>       </ul>       <ul class="nav navbar-nav navbar-right">         <li><a href="../navbar/">default</a></li>         <li><a href="./">static top <span class="sr-only">(current)</span></a></li>         <li><a href="../navbar-fixed-top/">fixed top</a></li>       </ul>     </div><!--/.nav-collapse -->   </div> </nav> 

your code seems work me. indicates you're missing javascript files. more precisely, missing bootstrap , jquery js files. inside <body>, add both files.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> 

keep in mind include jquery first, otherwise bootstrap won't work (bootstrap requires jquery, that's all).

here's code, working. i've copied markup , added bootstrap + jquery.

edit

i didn't notice you've been using wront data-target. @asifuzzaman redoy. change data-target following:

data-target=".navbar-collapse" 

i've updated fiddle accordingly.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -