Case
With this plugin you can add drop-down menus for almost everything, including navigation bars, tabs, and capsule buttons.
For navigation bars
The navigation bar is divided into four sections. The first part of the navigation head, the second part of the navigation column, the third part of form query form, part IV navigation column.
[JavaScript]View Plaincopy
- <nav class="NavBar navbar-default" role="navigation" >
- <div class="Navbar-header" >
- <button type="button" class="Navbar-toggle" data-toggle= "collapse" data-target= "#myCollapse ">
- <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="#" >Brand</a>
- </div>
- <div class="collapse navbar-collapse" id="Mycollapse" >
- <ul class="Nav navbar-nav" >
- <li class="active" ><a href="#" >Link</a></li>
- <li><a href="#" >Link</a></li>
- <li class="dropdown" >
- <a href="#" class="Dropdown-toggle" data-toggle="dropdown" >dropdown <b class=" Caret "></b></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 class="divider" ></li>
- <li><a href="#" >separated link</a></li>
- <li class="divider" ></li>
- <li><a href="#" >one more separated link</a></li>
- </ul>
- </li>
- </ul>
- <form class="Navbar-form navbar-left" role="search" >
- <div class="Form-group" >
- <input type="text" class="Form-control" placeholder="Search" >
- </div>
- <button type="Submit" class="btn btn-default" >Submit</button>
- </form>
- <ul class="nav navbar-nav navbar-right" >
- <li><a href="#" >Link</a></li>
- <li class="dropdown" >
- <a href="#" class="Dropdown-toggle" data-toggle="dropdown" >dropdown <b class=" Caret "></b></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 class="divider" ></li>
- <li><a href="#" >separated link</a></li>
- </ul>
- </li>
- </ul>
- </div>
- Lt;/nav>
Effect is
Usage one--through the Data property
data-toggle="dropdown"
You can turn the drop-down menu on or off by adding to a link or button.
<li class= "dropdown" > <a href= "#" class= "Dropdown-toggle" data-toggle= "dropdown ">dropdown <b class=" caret "></b></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 class= "Divider" ></li> <li><a href= "#" >separated link</a></li> <li class= "Divider" ></li> <li><a href= "#" >one more separated link</a></li> </ul> </li>
Usage two--through JavaScript
To open or close a drop-down menu via javascript:
Delete the Data-toggle attribute, then click again will not appear down the menu, next we add an onclick event to this a tag.
<script type= "Text/javascript" > function Test () { $ (' #myDropDown '). Dropdown (); } </ Script>
Then click on the A tab to see the drop-down menu.
The event can be bound and then automatically bound to the element when the element is processed accordingly, and the associated code is executed.
$ (' #myDropdown '). On (' Show.bs.dropdown ', function () { //To do some processing code at the time of display})
Bootstrap Learning JS plugin under the drop-down menu