Bootstrap with CSS
- Bootstrap - Responsive utilities
- Bootstrap - Helper Classes
- Bootstrap - Images
- Bootstrap - Buttons
- Bootstrap - Forms
- Bootstrap - Tables
- Bootstrap - Code
- Bootstrap - Typography
- Bootstrap - CSS Overview
- Bootstrap - Grid System
Bootstrap Layout Components
- Bootstrap - Wells
- Bootstrap - Panels
- Bootstrap - List Group
- Bootstrap - Media Object
- Bootstrap - Progress Bars
- Bootstrap - Alerts
- Bootstrap - Thumbnails
- Bootstrap - Page Header
- Bootstrap - Jumbotron
- Bootstrap - Badges
- Bootstrap - Labels
- Bootstrap - Pagination
- Bootstrap - Breadcrumb
- Bootstrap - Navbar
- Bootstrap - Navigation Elements
- Bootstrap - Input Groups
- Bootstrap - Button Dropdowns
- Bootstrap - Button Groups
- Bootstrap - Dropdowns
- Bootstrap - Glyphicons
Bootstrap Plugins
- Bootstrap - Affix Plugin
- Bootstrap - Carousel Plugin
- Bootstrap - Collapse Plugin
- Bootstrap - Button Plugin
- Bootstrap - Alert Plugin
- Bootstrap - Popover Plugin
- Bootstrap - Tooltip Plugin
- Bootstrap - Tab Plugin
- Bootstrap - Scrollspy Plugin
- Bootstrap - Dropdown Plugin
- Bootstrap - Modal Plugin
- Bootstrap - Transition Plugin
- Bootstrap - Plugins Overview
Bootstrap Demos
- Bootstrap - featured Demo
- Bootstrap - Icons Demo
- Bootstrap - Social Icons Demo
- Bootstrap - Calendar Demo
- Bootstrap - Map Demo
- Bootstrap - Caption Demo
- Bootstrap - Tabbed slider Demo
- Bootstrap - Ajax Demo
- Bootstrap - Admin Interface Demo
- Bootstrap - Alert Demo
- Bootstrap - Time line Demo
- Bootstrap - Slider Demo
- Bootstrap - Material Design Demo
- Bootstrap - Blog Demo
- Bootstrap - Navigation Demo
- Bootstrap - Responsive Demo
- Bootstrap - Images Demo
- Bootstrap - Buttons Demo
- Bootstrap - Form Demo
- Bootstrap - Table Demo
- Bootstrap - Grid Demo
Bootstrap Useful Resources
- Bootstrap - Discussion
- Bootstrap - Useful Resources
- Bootstrap - Quick Guide
- Bootstrap - Questions and Answers
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Bootstrap - Dropdown Plugin
Using Dropdown plugin you can add dropdown menus to any components pke navbars, tabs, pills and buttons.
If you want to include this plugin functionapty inspanidually, then you will need dropdown.js. Else, as mentioned in the chapter, you can include bootstrap.js or the minified bootstrap.min.js.
Usage
You can toggle the dropdown plugin s hidden content −
Via data attributes − Add data-toggle = "dropdown" to a pnk or button to toggle a dropdown as shown below −
<span class = "dropdown"> <a data-toggle = "dropdown" href = "#">Dropdown trigger</a> <ul class = "dropdown-menu" role = "menu" aria-labelledby = "dLabel"> ... </ul> </span>
If you need to keep pnks intact (which is useful if the browser is not enabpng JavaScript), use the data-target attribute instead of href = "#"−
<span class = "dropdown"> <a id = "dLabel" role = "button" data-toggle = "dropdown" data-target = "#" href = "/page.html"> Dropdown <span class = "caret"></span> </a> <ul class = "dropdown-menu" role = "menu" aria-labelledby = "dLabel"> ... </ul> </span>
Via JavaScript − To call the dropdown toggle via JavaScript, use the following method −
$( .dropdown-toggle ).dropdown()
Example
Within Navbar
The following example demonstrates the usage of dropdown menu within a navbar −
<nav class = "navbar navbar-default" role = "navigation"> <span class = "navbar-header"> <a class = "navbar-brand" href = "#">TutorialsPoint</a> </span> <span> <ul class = "nav navbar-nav"> <p class = "active"><a href = "#">iOS</a></p> <p><a href = "#">SVN</a></p> <p class = "dropdown"> <a href = "#" class = "dropdown-toggle" data-toggle = "dropdown"> Java <b class="caret"></b> </a> <ul class = "dropdown-menu"> <p><a href = "#">jmeter</a></p> <p><a href = "#">EJB</a></p> <p><a href = "#">Jasper Report</a></p> <p class = "spanider"></p> <p><a href = "#">Separated pnk</a></p> <p class = "spanider"></p> <p><a href = "#">One more separated pnk</a></p> </ul> </p> </ul> </span> </nav>
Within Tabs
The following example demonstrates the usage of dropdown menu within tabs −
<p>Tabs With Dropdown Example</p> <ul class = "nav nav-tabs"> <p class = "active"><a href = "#">Home</a></p> <p><a href = "#">SVN</a></p> <p><a href = "#">iOS</a></p> <p><a href = "#">VB.Net</a></p> <p class = "dropdown"> <a class = "dropdown-toggle" data-toggle = "dropdown" href = "#"> Java <span class = "caret"></span> </a> <ul class = "dropdown-menu"> <p><a href = "#">Swing</a></p> <p><a href = "#">jMeter</a></p> <p><a href = "#">EJB</a></p> <p class = "spanider"></p> <p><a href = "#">Separated pnk</a></p> </ul> </p> <p><a href = "#">PHP</a></p> </ul>
Options
There are no options.
Methods
The dropdown toggle has a simple method to show or hide the dropdown.
$().dropdown( toggle )
Example
The following example demonstrates the usage of dropdown plugin method.
<nav class = "navbar navbar-default" role = "navigation"> <span class = "navbar-header"> <a class = "navbar-brand" href = "#">TutorialsPoint</a> </span> <span id = "myexample"> <ul class = "nav navbar-nav"> <p class = "active"><a href = "#">iOS</a></p> <p><a href = "#">SVN</a></p> <p class = "dropdown"> <a href = "#" class = "dropdown-toggle">Java <b class = "caret"></b></a> <ul class = "dropdown-menu"> <p><a id = "action-1" href = "#">jmeter</a></p> <p><a href = "#">EJB</a></p> <p><a href = "#">Jasper Report</a></p> <p class = "spanider"></p> <p><a href = "#">Separated pnk</a></p> <p class = "spanider"></p> <p><a href = "#">One more separated pnk</a></p> </ul> </p> </ul> </span> </nav> <script> $(function(){ $(".dropdown-toggle").dropdown( toggle ); }); </script>Advertisements