Bootstrap Learning JS plugin under the drop-down menu

Source: Internet
Author: User
Tags button type

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
  1. <nav class="NavBar navbar-default" role="navigation" >
  2. <div class="Navbar-header" >
  3. <button type="button" class="Navbar-toggle" data-toggle= "collapse" data-target= "#myCollapse ">
  4. <span class="sr-only" >toggle navigation</span>
  5. <span class="Icon-bar" ></span>
  6. <span class="Icon-bar" ></span>
  7. <span class="Icon-bar" ></span>
  8. </button>
  9. <a class="Navbar-brand" href="#" >Brand</a>
  10. </div>
  11. <div class="collapse navbar-collapse" id="Mycollapse" >
  12. <ul class="Nav navbar-nav" >
  13. <li class="active" ><a href="#" >Link</a></li>
  14. <li><a href="#" >Link</a></li>
  15. <li class="dropdown" >
  16. <a href="#" class="Dropdown-toggle" data-toggle="dropdown" >dropdown <b class=" Caret "></b></a>
  17. <ul class="Dropdown-menu" >
  18. <li><a href="#" >Action</a></li>
  19. <li><a href="#" >another action</a></li>
  20. <li><a href="#" >something else here</a></li>
  21. <li class="divider" ></li>
  22. <li><a href="#" >separated link</a></li>
  23. <li class="divider" ></li>
  24. <li><a href="#" >one more separated link</a></li>
  25. </ul>
  26. </li>
  27. </ul>
  28. <form class="Navbar-form navbar-left" role="search" >
  29. <div class="Form-group" >
  30. <input type="text" class="Form-control" placeholder="Search" >
  31. </div>
  32. <button type="Submit" class="btn btn-default" >Submit</button>
  33. </form>
  34. <ul class="nav navbar-nav navbar-right" >
  35. <li><a href="#" >Link</a></li>
  36. <li class="dropdown" >
  37. <a href="#" class="Dropdown-toggle" data-toggle="dropdown" >dropdown <b class=" Caret "></b></a>
  38. <ul class="Dropdown-menu" >
  39. <li><a href="#" >Action</a></li>
  40. <li><a href="#" >another action</a></li>
  41. <li><a href="#" >something else here</a></li>
  42. <li class="divider" ></li>
  43. <li><a href="#" >separated link</a></li>
  44. </ul>
  45. </li>
  46. </ul>
  47. </div>
  48. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.