Easy Tutorial
❮ Bootstrap Buttons Bootstrap Progress Bars ❯

Bootstrap Plugin Overview

The components discussed in the Layout Components section earlier are just the beginning. Bootstrap comes with 12 jQuery plugins that extend functionality and add more interactivity to your site. Even if you are not an advanced JavaScript developer, you can start learning and using Bootstrap's JavaScript plugins. Most of these plugins can be triggered without writing any code, thanks to the Bootstrap Data API.

There are two ways to include Bootstrap plugins in your site:

Both bootstrap.js and bootstrap.min.js include all plugins.

Data Attributes

Programmatic API

We provide a pure JavaScript API for all Bootstrap plugins. All public APIs are callable individually or in a chain and return the collection of elements they operate on (similar to jQuery's calling style). For example:

$(".btn.danger").button("toggle").addClass("fat")

All methods can accept an optional options object, a string representing a specific method, or no parameters (in which case, the plugin will initialize with default behavior), as shown below:

// Initialize with default behavior
$("#myModal").modal()    
// Initialize with keyboard disabled               
$("#myModal").modal({ keyboard: false })  
// Initialize and immediately call show
$("#myModal").modal('show')

Each plugin also exposes its original constructor on the Constructor property: $.fn.popover.Constructor. If you need to get an instance of a specific plugin, you can directly retrieve it from an element:

$('[rel=popover]').data('popover')

Avoiding Namespace Conflicts

Sometimes Bootstrap plugins may need to be used alongside other UI frameworks, which can lead to namespace conflicts. If this happens, you can restore the original value by calling the plugin's .noConflict method.

// Return the previous value of $.fn.button
var bootstrapButton = $.fn.button.noConflict() 
// Assign Bootstrap functionality to $().bootstrapBtn                
$.fn.bootstrapBtn = bootstrapButton

Events

Bootstrap provides custom events for most plugins' unique actions. Generally, these events come in two forms:

❮ Bootstrap Buttons Bootstrap Progress Bars ❯