jquery - how to make navbar collapse after click one link in one page -


so have navbar dropdown link pages , in page (link 1 page), why collapse function on navbar cant work?

this code:

<nav class="navbar navbar-default navbar-fixed-top"> <div class="container">     <!-- brand , toggle grouped better mobile display -->     <div class="navbar-header">         <button type="button" data-target="#navbarcollapse" data-toggle="collapse" class="navbar-toggle">             <span class="sr-only">toggle navigation</span>             <span class="icon-bar"></span>             <span class="icon-bar"></span>             <span class="icon-bar"></span>         </button>     </div>     <!-- collection of nav links , other content toggling -->     <div id="navbarcollapse" class="collapse navbar-collapse">         <ul class="nav navbar-nav">             <li><a href="../content/main.php#home">home</a></li>             <li><a href="../content/emblem.php">emblem</a></li>             <li><a href="../content/history.php">history</a></li>             <li class="dropdown">             <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">the games <span class="caret"></span></a>                 <ul class="dropdown-menu">                     <li><a data-toggle="collapse" data-target=".navbar-collapse.in" href="#games2">water</a></li>                     <li><a data-toggle="collapse" data-target=".navbar-collapse.in" href="#games3">non-water</a></li>                 </ul>             </li>         </ul>     </div> </div> 

this code still link page

<li class="dropdown">             <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">the games <span class="caret"></span></a>                 <ul class="dropdown-menu">                     <li><a data-toggle="collapse" data-target=".navbar-collapse.in" href="#games2">water</a></li>                     <li><a data-toggle="collapse" data-target=".navbar-collapse.in" href="#games3">non-water</a></li>                 </ul>             </li> 

my question how make collapse work?

this collapse navbar:

css file:

/* dropdown navbar dropdown on hover */  .navbar-nav > li:hover > .dropdown-menu {      display: block;  }  .dropdown-submenu {      position: relative;  }    .dropdown-submenu>.dropdown-menu {      top: 0;      left: 100%;      margin-top: -6px;      margin-left: -1px;      -webkit-border-radius: 0 6px 6px 6px;      -moz-border-radius: 0 6px 6px;      border-radius: 0 6px 6px 6px;  }    .dropdown-submenu:hover>.dropdown-menu {      display: block;  }    .dropdown-submenu>a:after {      display: block;      content: " ";      float: right;      width: 0;      height: 0;      border-color: transparent;      border-style: solid;      border-width: 5px 0 5px 5px;      border-left-color: #ccc;      margin-top: 5px;      margin-right: -10px;  }
<!doctype html>    <html xmlns="http://www.w3.org/1999/xhtml">  <head runat="server">      <title></title>                <link href="stylesheet1.css" rel="stylesheet" />      <link href="content/bootstrap.css" rel="stylesheet" />      <link href="content/bootstrap.min.css" rel="stylesheet" />  </head>  <body>      <form id="form1" runat="server">      <div>                      <nav class="navbar navbar-default navbar-fixed-top">  <div class="container">      <!-- brand , toggle grouped better mobile display -->      <div class="navbar-header">          <button type="button" data-target="#navbarcollapse" data-toggle="collapse" class="navbar-toggle">              <span class="sr-only">toggle navigation</span>              <span class="icon-bar"></span>              <span class="icon-bar"></span>              <span class="icon-bar"></span>          </button>      </div>          <!-- collection of nav links , other content toggling -->      <div id="navbarcollapse" class="collapse navbar-collapse">          <ul class="nav navbar-nav">              <li><a href="../content/main.php#home">home</a></li>              <li><a href="../content/emblem.php">emblem</a></li>              <li><a href="../content/history.php">history</a></li>              <li class="dropdown">              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">the games <span class="caret"></span></a>                  <ul class="dropdown-menu">                      <li><a data-toggle="collapse" data-target=".navbar-collapse.in" href="#games2">water</a></li>                      <li><a data-toggle="collapse" data-target=".navbar-collapse.in" href="#games3">non-water</a></li>                  </ul>              </li>          </ul>      </div>  </div>          </nav>                </div>      </form>  </body>  </html>

make sure have stylesheet include: need bootstrap.css , bootstrap.min.css stylesheet1 example below.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -