Close a Div and Do Not Show Again on Refresh
JavaScript
Bring Bootstrap'southward components to life with over a dozen custom jQuery plugins. Easily include them all, or one by 1.
Individual or compiled
Plugins can be included individually (using Bootstrap's individual *.js files), or all at once (using bootstrap.js or the minified bootstrap.min.js).
Using the compiled JavaScript
Both bootstrap.js and bootstrap.min.js contain all plugins in a unmarried file. Include only i.
Plugin dependencies
Some plugins and CSS components depend on other plugins. If yous include plugins individually, make certain to check for these dependencies in the docs. Besides notation that all plugins depend on jQuery (this means jQuery must be included before the plugin files). Consult our bower.json to run into which versions of jQuery are supported.
Data attributes
Y'all can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap'due south first-class API and should be your first consideration when using a plugin.
That said, in some situations information technology may be desirable to turn this functionality off. Therefore, we also provide the power to disable the data attribute API by unbinding all events on the document namespaced with information-api. This looks like this:
$ ( certificate ). off ( '.data-api' ) Alternatively, to target a specific plugin, just include the plugin's name as a namespace along with the data-api namespace like this:
$ ( document ). off ( '.warning.data-api' ) Only one plugin per element via data attributes
Don't utilize data attributes from multiple plugins on the same chemical element. For example, a button cannot both have a tooltip and toggle a modal. To achieve this, employ a wrapping element.
Programmatic API
We too believe you should exist able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and render the collection acted upon.
$ ( '.btn.danger' ). button ( 'toggle' ). addClass ( 'fat' ) All methods should have an optional options object, a string which targets a particular method, or nothing (which initiates a plugin with default beliefs):
$ ( '#myModal' ). modal () // initialized with defaults $ ( '#myModal' ). modal ({ keyboard : false }) // initialized with no keyboard $ ( '#myModal' ). modal ( 'show' ) // initializes and invokes bear witness immediately Each plugin also exposes its raw constructor on a Constructor property: $.fn.popover.Constructor. If you'd like to become a detail plugin instance, retrieve it direct from an element: $('[rel="popover"]').data('popover').
Default settings
You can change the default settings for a plugin by modifying the plugin'southward Constructor.DEFAULTS object:
$ . fn . modal . Constructor . DEFAULTS . keyboard = false // changes default for the modal plugin's `keyboard` choice to false No conflict
Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions tin occasionally occur. If this happens, you may telephone call .noConflict on the plugin yous wish to revert the value of.
var bootstrapButton = $ . fn . button . noConflict () // return $.fn.button to previously assigned value $ . fn . bootstrapBtn = bootstrapButton // requite $().bootstrapBtn the Bootstrap functionality Events
Bootstrap provides custom events for most plugins' unique deportment. Generally, these come up in an infinitive and past participle form - where the infinitive (ex. show) is triggered at the start of an event, and its past participle form (ex. shown) is triggered on the completion of an action.
Every bit of 3.0.0, all Bootstrap events are namespaced.
All infinitive events provide preventDefault functionality. This provides the power to stop the execution of an action before it starts.
$ ( '#myModal' ). on ( 'prove.bs.modal' , office ( e ) { if ( ! data ) return e . preventDefault () // stops modal from being shown }) Version numbers
The version of each of Bootstrap's jQuery plugins can exist accessed via the VERSION property of the plugin'due south constructor. For example, for the tooltip plugin:
$ . fn . tooltip . Constructor . VERSION // => "3.3.7" No special fallbacks when JavaScript is disabled
Bootstrap's plugins don't autumn dorsum particularly gracefully when JavaScript is disabled. If you lot care about the user feel in this case, use <noscript> to explicate the situation (and how to re-enable JavaScript) to your users, and/or add your own custom fallbacks.
Third-party libraries
Bootstrap does not officially support third-political party JavaScript libraries like Prototype or jQuery UI. Despite .noConflict and namespaced events, there may be compatibility problems that you need to ready on your own.
About transitions
For simple transition effects, include transition.js once aslope the other JS files. If y'all're using the compiled (or minified) bootstrap.js, there is no need to include this—it'southward already there.
What's inside
Transition.js is a bones helper for transitionEnd events likewise as a CSS transition emulator. It's used by the other plugins to cheque for CSS transition support and to grab hanging transitions.
Disabling transitions
Transitions can be globally disabled using the following JavaScript snippet, which must come after transition.js (or bootstrap.js or bootstrap.min.js, as the case may exist) has loaded:
$ . support . transition = imitation Modals are streamlined, simply flexible, dialog prompts with the minimum required functionality and smart defaults.
Multiple open modals not supported
Be sure non to open up a modal while some other is still visible. Showing more than than one modal at a time requires custom code.
Modal markup placement
Ever try to place a modal's HTML code in a top-level position in your document to avert other components affecting the modal's appearance and/or functionality.
Due to how HTML5 defines its semantics, the autofocus HTML aspect has no issue in Bootstrap modals. To achieve the aforementioned result, use some custom JavaScript:
$ ( '#myModal' ). on ( 'shown.bs.modal' , part () { $ ( '#myInput' ). focus () }) Examples
Static instance
A rendered modal with header, body, and set of actions in the footer.
<div class= "modal fade" tabindex= "-1" role= "dialog" > <div class= "modal-dialog" role= "certificate" > <div grade= "modal-content" > <div course= "modal-header" > <button type= "button" form= "shut" data-dismiss= "modal" aria-label= "Shut" ><span aria-hidden= "true" > × </bridge></button> <h4 grade= "modal-title" >Modal title</h4> </div> <div class= "modal-body" > <p>One fine body… </p> </div> <div class= "modal-footer" > <button type= "push" course= "btn btn-default" data-dismiss= "modal" >Close</button> <button type= "button" class= "btn btn-chief" >Relieve changes</button> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> Live demo
Toggle a modal via JavaScript past clicking the button below. Information technology will slide down and fade in from the top of the folio.
<!-- Push button trigger modal --> <button type= "push button" form= "btn btn-master btn-lg" data-toggle= "modal" data-target= "#myModal" > Launch demo modal </button> <!-- Modal --> <div grade= "modal fade" id= "myModal" tabindex= "-1" role= "dialog" aria-labelledby= "myModalLabel" > <div class= "modal-dialog" part= "document" > <div class= "modal-content" > <div class= "modal-header" > <push type= "button" grade= "shut" data-dismiss= "modal" aria-label= "Close" ><span aria-hidden= "true" > × </span></push button> <h4 class= "modal-championship" id= "myModalLabel" >Modal championship</h4> </div> <div class= "modal-body" > ... </div> <div form= "modal-footer" > <button type= "button" class= "btn btn-default" data-dismiss= "modal" >Close</button> <button blazon= "button" class= "btn btn-master" >Save changes</push> </div> </div> </div> </div> Make modals accessible
Be certain to add role="dialog" and aria-labelledby="...", referencing the modal championship, to .modal, and role="document" to the .modal-dialog itself.
Additionally, you may give a description of your modal dialog with aria-describedby on .modal.
Embedding YouTube videos
Embedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically stop playback and more. Run into this helpful Stack Overflow post for more than data.
Optional sizes
Modals have two optional sizes, bachelor via modifier classes to be placed on a .modal-dialog.
<!-- Large modal --> <push button type= "push" class= "btn btn-master" data-toggle= "modal" information-target= ".bs-instance-modal-lg" >Large modal</button> <div grade= "modal fade bs-example-modal-lg" tabindex= "-ane" role= "dialog" aria-labelledby= "myLargeModalLabel" > <div class= "modal-dialog modal-lg" function= "certificate" > <div class= "modal-content" > ... </div> </div> </div> <!-- Small-scale modal --> <button type= "push button" class= "btn btn-primary" data-toggle= "modal" data-target= ".bs-example-modal-sm" >Minor modal</button> <div grade= "modal fade bs-example-modal-sm" tabindex= "-1" role= "dialog" aria-labelledby= "mySmallModalLabel" > <div class= "modal-dialog modal-sm" role= "document" > <div class= "modal-content" > ... </div> </div> </div> Remove animation
For modals that just appear rather than fade in to view, remove the .fade class from your modal markup.
<div class= "modal" tabindex= "-one" office= "dialog" aria-labelledby= "..." > ... </div> Using the grid system
To have reward of the Bootstrap grid system within a modal, just nest .rows within the .modal-trunk and and then use the normal filigree system classes.
<div class= "modal fade" tabindex= "-ane" role= "dialog" aria-labelledby= "gridSystemModalLabel" > <div course= "modal-dialog" part= "certificate" > <div class= "modal-content" > <div class= "modal-header" > <button type= "button" course= "close" data-dismiss= "modal" aria-label= "Close" ><span aria-subconscious= "true" > × </span></button> <h4 grade= "modal-title" id= "gridSystemModalLabel" >Modal championship</h4> </div> <div class= "modal-torso" > <div grade= "row" > <div class= "col-dr.-4" >.col-doctor-iv</div> <div course= "col-md-4 col-md-commencement-iv" >.col-md-4 .col-doctor-offset-4</div> </div> <div class= "row" > <div class= "col-medico-three col-md-first-3" >.col-medico-3 .col-doc-kickoff-3</div> <div class= "col-md-2 col-md-offset-4" >.col-md-two .col-medico-offset-four</div> </div> <div course= "row" > <div form= "col-md-6 col-md-first-3" >.col-md-6 .col-md-get-go-iii</div> </div> <div class= "row" > <div class= "col-sm-9" > Level 1: .col-sm-nine <div course= "row" > <div class= "col-xs-eight col-sm-6" > Level 2: .col-xs-8 .col-sm-6 </div> <div class= "col-xs-4 col-sm-half dozen" > Level 2: .col-xs-4 .col-sm-6 </div> </div> </div> </div> </div> <div form= "modal-footer" > <button type= "push" class= "btn btn-default" data-dismiss= "modal" >Close</push button> <button blazon= "push" class= "btn btn-primary" >Save changes</push> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> Have a agglomeration of buttons that all trigger the same modal, only with slightly dissimilar contents? Use effect.relatedTarget and HTML data-* attributes (perhaps via jQuery) to vary the contents of the modal depending on which button was clicked. See the Modal Events docs for details on relatedTarget,
<button type= "push" class= "btn btn-principal" data-toggle= "modal" data-target= "#exampleModal" data-whatever= "@mdo" >Open up modal for @mdo</push> <button type= "button" form= "btn btn-principal" data-toggle= "modal" data-target= "#exampleModal" data-any= "@fat" >Open modal for @fatty</push> <button type= "button" class= "btn btn-main" data-toggle= "modal" information-target= "#exampleModal" data-whatever= "@getbootstrap" >Open modal for @getbootstrap</button> ...more buttons... <div class= "modal fade" id= "exampleModal" tabindex= "-1" role= "dialog" aria-labelledby= "exampleModalLabel" > <div class= "modal-dialog" role= "document" > <div class= "modal-content" > <div course= "modal-header" > <button type= "button" form= "close" data-dismiss= "modal" aria-label= "Close" ><span aria-hidden= "true" > × </span></button> <h4 grade= "modal-title" id= "exampleModalLabel" >New message</h4> </div> <div class= "modal-body" > <form> <div class= "form-grouping" > <label for= "recipient-name" form= "control-label" >Recipient:</label> <input type= "text" grade= "form-command" id= "recipient-name" > </div> <div class= "form-grouping" > <label for= "message-text" grade= "control-characterization" >Message:</label> <textarea class= "form-control" id= "message-text" ></textarea> </div> </course> </div> <div course= "modal-footer" > <button type= "button" class= "btn btn-default" data-dismiss= "modal" >Close</push> <button type= "button" course= "btn btn-master" >Send message</button> </div> </div> </div> </div> $ ( '#exampleModal' ). on ( 'bear witness.bs.modal' , office ( upshot ) { var button = $ ( event . relatedTarget ) // Button that triggered the modal var recipient = button . information ( 'whatsoever' ) // Excerpt info from data-* attributes // If necessary, you could initiate an AJAX request here (and then exercise the updating in a callback). // Update the modal's content. We'll use jQuery hither, merely you could use a information binding library or other methods instead. var modal = $ ( this ) modal . find ( '.modal-title' ). text ( 'New message to ' + recipient ) modal . notice ( '.modal-body input' ). val ( recipient ) }) Usage
The modal plugin toggles your subconscious content on need, via data attributes or JavaScript. It as well adds .modal-open to the <body> to override default scrolling behavior and generates a .modal-backdrop to provide a click area for dismissing shown modals when clicking outside the modal.
Via data attributes
Actuate a modal without writing JavaScript. Set data-toggle="modal" on a controller element, like a button, along with a information-target="#foo" or href="#foo" to target a specific modal to toggle.
<button type= "push" data-toggle= "modal" information-target= "#myModal" >Launch modal</push button> Via JavaScript
Phone call a modal with id myModal with a single line of JavaScript:
$ ( '#myModal' ). modal ( options ) Options
Options tin can be passed via data attributes or JavaScript. For information attributes, append the option name to data-, as in information-backdrop="".
| Name | type | default | description |
|---|---|---|---|
| backdrop | boolean or the string 'static' | true | Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click. |
| keyboard | boolean | truthful | Closes the modal when escape key is pressed |
| evidence | boolean | true | Shows the modal when initialized. |
| remote | path | false | This option is deprecated since v3.3.0 and has been removed in v4. Nosotros recommend instead using client-side templating or a data binding framework, or calling jQuery.load yourself. If a remote URL is provided, content volition be loaded ane fourth dimension via jQuery's |
Methods
.modal(options)
Activates your content as a modal. Accepts an optional options object.
$ ( '#myModal' ). modal ({ keyboard : false }) .modal('toggle')
Manually toggles a modal. Returns to the caller before the modal has really been shown or subconscious (i.e. before the shown.bs.modal or subconscious.bs.modal event occurs).
$ ( '#myModal' ). modal ( 'toggle' ) .modal('show')
Manually opens a modal. Returns to the caller before the modal has actually been shown (i.e. earlier the shown.bs.modal event occurs).
$ ( '#myModal' ). modal ( 'bear witness' ) .modal('hibernate')
Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.eastward. earlier the hidden.bs.modal result occurs).
$ ( '#myModal' ). modal ( 'hide' ) .modal('handleUpdate')
Readjusts the modal'southward positioning to counter a scrollbar in case one should appear, which would make the modal jump to the left.
Only needed when the height of the modal changes while it is open.
$ ( '#myModal' ). modal ( 'handleUpdate' ) Events
Bootstrap'south modal class exposes a few events for hooking into modal functionality.
All modal events are fired at the modal itself (i.e. at the <div form="modal">).
| Outcome Type | Description |
|---|---|
| show.bs.modal | This event fires immediately when the show instance method is called. If caused by a click, the clicked element is bachelor as the relatedTarget property of the result. |
| shown.bs.modal | This result is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked chemical element is available as the relatedTarget belongings of the effect. |
| hide.bs.modal | This result is fired immediately when the hide instance method has been called. |
| subconscious.bs.modal | This outcome is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete). |
| loaded.bs.modal | This event is fired when the modal has loaded content using the remote option. |
$ ( '#myModal' ). on ( 'hidden.bs.modal' , function ( due east ) { // exercise something... }) Examples
Add dropdown menus to nearly annihilation with this simple plugin, including the navbar, tabs, and pills.
Within a navbar
Inside pills
Usage
Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .open up form on the parent list item.
On mobile devices, opening a dropdown adds a .dropdown-backdrop as a tap area for closing dropdown menus when tapping exterior the menu, a requirement for proper iOS support. This means that switching from an open dropdown carte to a different dropdown card requires an extra tap on mobile.
Notation: The information-toggle="dropdown" attribute is relied on for endmost dropdown menus at an application level, and so information technology'southward a practiced idea to always use it.
Via information attributes
Add information-toggle="dropdown" to a link or button to toggle a dropdown.
<div class= "dropdown" > <button id= "dLabel" type= "button" data-toggle= "dropdown" aria-haspopup= "true" aria-expanded= "faux" > Dropdown trigger <span class= "caret" ></span> </push button> <ul class= "dropdown-menu" aria-labelledby= "dLabel" > ... </ul> </div> To keep URLs intact with link buttons, use the data-target aspect instead of href="#".
<div class= "dropdown" > <a id= "dLabel" data-target= "#" href= "http://instance.com/" data-toggle= "dropdown" function= "button" aria-haspopup= "true" aria-expanded= "false" > Dropdown trigger <span course= "caret" ></span> </a> <ul course= "dropdown-card" aria-labelledby= "dLabel" > ... </ul> </div> Via JavaScript
Phone call the dropdowns via JavaScript:
$ ( '.dropdown-toggle' ). dropdown () data-toggle="dropdown" notwithstanding required
Regardless of whether you call your dropdown via JavaScript or instead use the data-api, data-toggle="dropdown" is ever required to exist present on the dropdown's trigger element.
Options
None
Methods
$().dropdown('toggle')
Toggles the dropdown menu of a given navbar or tabbed navigation.
Events
All dropdown events are fired at the .dropdown-menu's parent element.
All dropdown events accept a relatedTarget property, whose value is the toggling anchor element.
| Result Type | Clarification |
|---|---|
| show.bs.dropdown | This upshot fires immediately when the show case method is called. |
| shown.bs.dropdown | This outcome is fired when the dropdown has been made visible to the user (will await for CSS transitions, to consummate). |
| hide.bs.dropdown | This effect is fired immediately when the hide instance method has been called. |
| hidden.bs.dropdown | This event is fired when the dropdown has finished being hidden from the user (will await for CSS transitions, to complete). |
$ ( '#myDropdown' ). on ( 'show.bs.dropdown' , role () { // do something… }) The ScrollSpy plugin is for automatically updating nav targets based on scroll position. Scroll the area below the navbar and spotter the active class change. The dropdown sub items will be highlighted every bit well.
Requires relative positioning
No matter the implementation method, scrollspy requires the use of position: relative; on the element you're spying on. In virtually cases this is the <body>. When scrollspying on elements other than the <body>, be sure to have a summit set and overflow-y: scroll; applied.
Via data attributes
To easily add scrollspy behavior to your topbar navigation, add together data-spy="scroll" to the element you want to spy on (most typically this would be the <body>). Then add the data-target aspect with the ID or course of the parent element of whatever Bootstrap .nav component.
body { position : relative ; } <body information-spy= "curlicue" data-target= "#navbar-example" > ... <div id= "navbar-example" > <ul class= "nav nav-tabs" office= "tablist" > ... </ul> </div> ... </body> Via JavaScript
Later on adding position: relative; in your CSS, phone call the scrollspy via JavaScript:
$ ( 'body' ). scrollspy ({ target : '#navbar-example' }) Methods
.scrollspy('refresh')
When using scrollspy in conjunction with adding or removing of elements from the DOM, you lot'll need to telephone call the refresh method like then:
$ ( '[information-spy="scroll"]' ). each ( function () { var $spy = $ ( this ). scrollspy ( 'refresh' ) }) Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option proper name to data-, every bit in data-commencement="".
| Name | type | default | description |
|---|---|---|---|
| start | number | 10 | Pixels to offset from top when computing position of scroll. |
Events
| Event Type | Clarification |
|---|---|
| activate.bs.scrollspy | This outcome fires whenever a new item becomes activated by the scrollspy. |
$ ( '#myScrollspy' ). on ( 'actuate.bs.scrollspy' , function () { // do something… }) Example tabs
Add quick, dynamic tab functionality to transition through panes of local content, fifty-fifty via dropdown menus. Nested tabs are non supported.
Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
Nutrient truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +i labore velit, blog sartorial PBR leggings adjacent level wes anderson artisan four loko farm-to-tabular array craft beer twee. Qui photo booth letterpress, commodo enim arts and crafts beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY upstanding culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
Etsy mixtape wayfarers, upstanding wes anderson tofu before they sold out mcsweeney'due south organic lomo retro fanny pack lo-fi subcontract-to-tabular array readymade. Messenger purse gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-costless, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl arts and crafts beer blog stumptown. Pitchfork sustainable tofu synth chambray year.
Trust fund seitan letterpress, keytar raw denim keffiyeh etsy fine art party earlier they sold out primary cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art political party locavore wolf cliche loftier life repeat park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out subcontract-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.
Usage
Enable tabbable tabs via JavaScript (each tab needs to exist activated individually):
$ ( '#myTabs a' ). click ( office ( e ) { east . preventDefault () $ ( this ). tab ( 'show' ) }) Yous can actuate individual tabs in several means:
$ ( '#myTabs a[href="#profile"]' ). tab ( 'show' ) // Select tab past proper name $ ( '#myTabs a:first' ). tab ( 'show' ) // Select first tab $ ( '#myTabs a:last' ). tab ( 'bear witness' ) // Select last tab $ ( '#myTabs li:eq(two) a' ). tab ( 'show' ) // Select tertiary tab (0-indexed) Markup
Yous can activate a tab or pill navigation without writing any JavaScript by only specifying data-toggle="tab" or information-toggle="pill" on an element. Adding the nav and nav-tabs classes to the tab ul will apply the Bootstrap tab styling, while adding the nav and nav-pills classes volition employ pill styling.
<div> <!-- Nav tabs --> <ul class= "nav nav-tabs" function= "tablist" > <li part= "presentation" course= "agile" ><a href= "#domicile" aria-controls= "habitation" role= "tab" data-toggle= "tab" >Dwelling house</a></li> <li role= "presentation" ><a href= "#contour" aria-controls= "profile" part= "tab" data-toggle= "tab" >Profile</a></li> <li role= "presentation" ><a href= "#messages" aria-controls= "messages" part= "tab" data-toggle= "tab" >Messages</a></li> <li office= "presentation" ><a href= "#settings" aria-controls= "settings" role= "tab" data-toggle= "tab" >Settings</a></li> </ul> <!-- Tab panes --> <div class= "tab-content" > <div office= "tabpanel" class= "tab-pane agile" id= "home" >...</div> <div role= "tabpanel" class= "tab-pane" id= "contour" >...</div> <div role= "tabpanel" class= "tab-pane" id= "messages" >...</div> <div role= "tabpanel" class= "tab-pane" id= "settings" >...</div> </div> </div> Fade effect
To make tabs fade in, add .fade to each .tab-pane. The beginning tab pane must also take .in to make the initial content visible.
<div class= "tab-content" > <div role= "tabpanel" course= "tab-pane fade in agile" id= "abode" >...</div> <div role= "tabpanel" class= "tab-pane fade" id= "profile" >...</div> <div function= "tabpanel" grade= "tab-pane fade" id= "messages" >...</div> <div role= "tabpanel" class= "tab-pane fade" id= "settings" >...</div> </div> Methods
$().tab
Activates a tab chemical element and content container. Tab should take either a data-target or an href targeting a container node in the DOM. In the above examples, the tabs are the <a>s with information-toggle="tab" attributes.
.tab('show')
Selects the given tab and shows its associated content. Any other tab that was previously selected becomes unselected and its associated content is subconscious. Returns to the caller earlier the tab pane has actually been shown (i.e. before the shown.bs.tab upshot occurs).
$ ( '#someTab' ). tab ( 'bear witness' ) Events
When showing a new tab, the events fire in the following order:
-
hibernate.bs.tab(on the current active tab) -
show.bs.tab(on the to-exist-shown tab) -
hidden.bs.tab(on the previous active tab, the aforementioned ane every bit for thehide.bs.tabevent) -
shown.bs.tab(on the newly-agile just-shown tab, the same ane as for thetestify.bs.tabevent)
If no tab was already active, then the hide.bs.tab and hidden.bs.tab events will not be fired.
| Upshot Type | Clarification |
|---|---|
| testify.bs.tab | This event fires on tab prove, simply before the new tab has been shown. Utilize event.target and consequence.relatedTarget to target the active tab and the previous agile tab (if available) respectively. |
| shown.bs.tab | This result fires on tab show after a tab has been shown. Utilise effect.target and effect.relatedTarget to target the active tab and the previous active tab (if bachelor) respectively. |
| hide.bs.tab | This event fires when a new tab is to exist shown (and thus the previous active tab is to be hidden). Utilise result.target and outcome.relatedTarget to target the current active tab and the new presently-to-be-agile tab, respectively. |
| hidden.bs.tab | This outcome fires after a new tab is shown (and thus the previous active tab is subconscious). Use outcome.target and event.relatedTarget to target the previous active tab and the new active tab, respectively. |
$ ( 'a[data-toggle="tab"]' ). on ( 'shown.bs.tab' , function ( due east ) { e . target // newly activated tab east . relatedTarget // previous active tab }) Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.
Tooltips with zero-length titles are never displayed.
Hover over the links below to see tooltips:
Tight pants next level keffiyeh you probably oasis't heard of them. Photograph booth bristles raw denim letterpress vegan messenger purse stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-fleck american clothes accept a terry richardson vinyl chambray. Bristles stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, iv loko mcsweeney's cleanse vegan chambray. A really ironic artisan whatever keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.
Static tooltip
Four options are bachelor: top, right, bottom, and left aligned.
Four directions
<button type= "push" form= "btn btn-default" data-toggle= "tooltip" information-placement= "left" championship= "Tooltip on left" >Tooltip on left</push button> <push button type= "push button" class= "btn btn-default" data-toggle= "tooltip" data-placement= "top" title= "Tooltip on top" >Tooltip on top</button> <push button blazon= "push button" form= "btn btn-default" data-toggle= "tooltip" data-placement= "bottom" title= "Tooltip on lesser" >Tooltip on bottom</push button> <button type= "button" course= "btn btn-default" data-toggle= "tooltip" data-placement= "right" championship= "Tooltip on right" >Tooltip on correct</push> The tooltip plugin generates content and markup on need, and by default places tooltips after their trigger element.
Trigger the tooltip via JavaScript:
$ ( '#case' ). tooltip ( options ) Markup
The required markup for a tooltip is just a data attribute and title on the HTML element you wish to take a tooltip. The generated markup of a tooltip is rather simple, though it does require a position (by default, set to pinnacle by the plugin).
<!-- HTML to write --> <a href= "#" information-toggle= "tooltip" title= "Some tooltip text!" >Hover over me</a> <!-- Generated markup by the plugin --> <div class= "tooltip top" role= "tooltip" > <div class= "tooltip-arrow" ></div> <div grade= "tooltip-inner" > Some tooltip text! </div> </div> Options
Options can be passed via data attributes or JavaScript. For data attributes, append the pick name to information-, as in information-animation="".
| Name | Blazon | Default | Description |
|---|---|---|---|
| blitheness | boolean | true | Apply a CSS fade transition to the tooltip |
| container | string | fake | faux | Appends the tooltip to a specific chemical element. Example: |
| delay | number | object | 0 | Delay showing and hiding the tooltip (ms) - does not apply to manual trigger blazon If a number is supplied, delay is applied to both hibernate/show Object structure is: |
| html | boolean | false | Insert HTML into the tooltip. If false, jQuery's text method will be used to insert content into the DOM. Utilize text if you're worried well-nigh XSS attacks. |
| placement | string | function | 'tiptop' | How to position the tooltip - top | bottom | left | right | auto. When a function is used to determine the placement, it is called with the tooltip DOM node equally its start argument and the triggering element DOM node equally its 2d. The |
| selector | cord | false | If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to take tooltips added. See this and an informative example. |
| template | string | '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' | Base of operations HTML to utilise when creating the tooltip. The tooltip'due south The outermost wrapper element should have the |
| championship | string | part | '' | Default title value if If a role is given, information technology will exist called with its |
| trigger | string | 'hover focus' | How tooltip is triggered - click | hover | focus | transmission. You lot may laissez passer multiple triggers; separate them with a space. manual cannot be combined with whatsoever other trigger. |
| viewport | string | object | function | { selector: 'trunk', padding: 0 } | Keeps the tooltip within the bounds of this element. Example: If a office is given, information technology is called with the triggering element DOM node as its only argument. The |
Methods
$().tooltip(options)
Attaches a tooltip handler to an chemical element collection.
.tooltip('prove')
Reveals an chemical element's tooltip. Returns to the caller earlier the tooltip has actually been shown (i.eastward. before the shown.bs.tooltip outcome occurs). This is considered a "manual" triggering of the tooltip. Tooltips with zero-length titles are never displayed.
$ ( '#element' ). tooltip ( 'show' ) .tooltip('hibernate')
Hides an element's tooltip. Returns to the caller before the tooltip has actually been hidden (i.e. before the hidden.bs.tooltip event occurs). This is considered a "transmission" triggering of the tooltip.
$ ( '#chemical element' ). tooltip ( 'hide' ) .tooltip('toggle')
Toggles an element's tooltip. Returns to the caller before the tooltip has actually been shown or subconscious (i.e. before the shown.bs.tooltip or hidden.bs.tooltip event occurs). This is considered a "manual" triggering of the tooltip.
$ ( '#element' ). tooltip ( 'toggle' ) .tooltip('destroy')
Hides and destroys an element'south tooltip. Tooltips that use delegation (which are created using the selector selection) cannot be individually destroyed on descendant trigger elements.
$ ( '#element' ). tooltip ( 'destroy' ) Events
| Result Type | Description |
|---|---|
| evidence.bs.tooltip | This event fires immediately when the testify instance method is chosen. |
| shown.bs.tooltip | This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to consummate). |
| hide.bs.tooltip | This result is fired immediately when the hide example method has been called. |
| subconscious.bs.tooltip | This outcome is fired when the tooltip has finished beingness hidden from the user (volition wait for CSS transitions to consummate). |
| inserted.bs.tooltip | This upshot is fired later the show.bs.tooltip upshot when the tooltip template has been added to the DOM. |
$ ( '#myTooltip' ). on ( 'hidden.bs.tooltip' , function () { // do something… }) Add small overlays of content, like those on the iPad, to any chemical element for housing secondary information.
Popovers whose both title and content are zero-length are never displayed.
Opt-in functionality
For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
One mode to initialize all popovers on a page would exist to select them by their data-toggle aspect:
$ ( function () { $ ( '[data-toggle="popover"]' ). popover () }) Popovers in button groups, input groups, and tables require special setting
When using popovers on elements within a .btn-group or an .input-group, or on table-related elements (<td>, <th>, <tr>, <thead>, <tbody>, <tfoot>), you'll have to specify the selection container: 'torso' (documented below) to avoid unwanted side effects (such as the chemical element growing wider and/or losing its rounded corners when the popover is triggered).
Popovers on disabled elements require wrapper elements
To add a popover to a disabled or .disabled chemical element, put the element within of a <div> and employ the popover to that <div> instead.
Multiple-line links
Sometimes y'all want to add a popover to a hyperlink that wraps multiple lines. The default behavior of the popover plugin is to eye information technology horizontally and vertically. Add white-infinite: nowrap; to your anchors to avoid this.
Examples
Static popover
Four options are available: top, correct, bottom, and left aligned.
Popover tiptop
Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Popover right
Sed posuere consectetur est at lobortis. Aenean european union leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Popover bottom
Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Popover left
Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Live demo
<push button type= "button" class= "btn btn-lg btn-danger" data-toggle= "popover" championship= "Popover title" data-content= "And here's some amazing content. It's very engaging. Right?" >Click to toggle popover</push button> Iv directions
<button type= "push" class= "btn btn-default" data-container= "torso" data-toggle= "popover" information-placement= "left" data-content= "Vivamus sagittis lacus vel augue laoreet rutrum faucibus." > Popover on left </push button> <button type= "button" class= "btn btn-default" data-container= "body" data-toggle= "popover" data-placement= "elevation" data-content= "Vivamus sagittis lacus vel augue laoreet rutrum faucibus." > Popover on top </button> <button type= "button" class= "btn btn-default" data-container= "trunk" information-toggle= "popover" data-placement= "bottom" data-content= "Vivamus sagittis lacus vel augue laoreet rutrum faucibus." > Popover on lesser </button> <button type= "button" form= "btn btn-default" data-container= "torso" data-toggle= "popover" data-placement= "right" information-content= "Vivamus sagittis lacus vel augue laoreet rutrum faucibus." > Popover on right </button> Dismiss on next click
Use the focus trigger to dismiss popovers on the side by side click that the user makes.
Specific markup required for dismiss-on-next-click
For proper cantankerous-browser and cross-platform behavior, you must use the <a> tag, non the <push button> tag, and you likewise must include the role="button" and tabindex attributes.
<a tabindex= "0" class= "btn btn-lg btn-danger" role= "push button" data-toggle= "popover" information-trigger= "focus" title= "Dismissible popover" data-content= "And here's some astonishing content. Information technology's very engaging. Right?" >Dismissible popover</a> Usage
Enable popovers via JavaScript:
$ ( '#example' ). popover ( options ) Options
Options can be passed via data attributes or JavaScript. For information attributes, suspend the option proper noun to data-, as in data-blitheness="".
| Name | Blazon | Default | Clarification |
|---|---|---|---|
| animation | boolean | true | Apply a CSS fade transition to the popover |
| container | string | false | faux | Appends the popover to a specific element. Example: |
| content | string | function | '' | Default content value if If a function is given, it will be called with its |
| filibuster | number | object | 0 | Filibuster showing and hiding the popover (ms) - does not utilise to manual trigger type If a number is supplied, delay is applied to both hide/prove Object structure is: |
| html | boolean | false | Insert HTML into the popover. If false, jQuery's text method volition be used to insert content into the DOM. Use text if you're worried well-nigh XSS attacks. |
| placement | cord | function | 'correct' | How to position the popover - superlative | bottom | left | right | auto. When a function is used to decide the placement, it is called with the popover DOM node equally its first statement and the triggering element DOM node as its 2d. The |
| selector | string | false | If a selector is provided, popover objects will exist delegated to the specified targets. In exercise, this is used to enable dynamic HTML content to have popovers added. Run into this and an informative instance. |
| template | string | '<div class="popover" role="tooltip"><div class="arrow"></div><h3 grade="popover-title"></h3><div class="popover-content"></div></div>' | Base HTML to employ when creating the popover. The popover'southward The popover's The outermost wrapper element should have the |
| title | cord | function | '' | Default title value if If a role is given, it will exist chosen with its |
| trigger | string | 'click' | How popover is triggered - click | hover | focus | transmission. You may laissez passer multiple triggers; separate them with a space. transmission cannot exist combined with whatsoever other trigger. |
| viewport | cord | object | function | { selector: 'body', padding: 0 } | Keeps the popover within the bounds of this chemical element. Example: If a function is given, it is called with the triggering chemical element DOM node as its only argument. The |
Information attributes for individual popovers
Options for private popovers tin alternatively be specified through the employ of data attributes, equally explained above.
Methods
$().popover(options)
Initializes popovers for an element collection.
.popover('show')
Reveals an chemical element'due south popover. Returns to the caller earlier the popover has actually been shown (i.east. before the shown.bs.popover effect occurs). This is considered a "manual" triggering of the popover. Popovers whose both title and content are nil-length are never displayed.
$ ( '#element' ). popover ( 'show' ) .popover('hibernate')
Hides an element's popover. Returns to the caller earlier the popover has really been hidden (i.e. before the subconscious.bs.popover event occurs). This is considered a "transmission" triggering of the popover.
$ ( '#chemical element' ). popover ( 'hibernate' ) .popover('toggle')
Toggles an element's popover. Returns to the caller before the popover has actually been shown or subconscious (i.due east. before the shown.bs.popover or hidden.bs.popover event occurs). This is considered a "manual" triggering of the popover.
$ ( '#chemical element' ). popover ( 'toggle' ) .popover('destroy')
Hides and destroys an chemical element'due south popover. Popovers that use delegation (which are created using the selector option) cannot be individually destroyed on descendant trigger elements.
$ ( '#element' ). popover ( 'destroy' ) Events
| Event Type | Description |
|---|---|
| show.bs.popover | This event fires immediately when the show instance method is called. |
| shown.bs.popover | This event is fired when the popover has been fabricated visible to the user (will wait for CSS transitions to complete). |
| hibernate.bs.popover | This issue is fired immediately when the hide instance method has been chosen. |
| hidden.bs.popover | This event is fired when the popover has finished being hidden from the user (will look for CSS transitions to complete). |
| inserted.bs.popover | This outcome is fired afterward the show.bs.popover result when the popover template has been added to the DOM. |
$ ( '#myPopover' ). on ( 'hidden.bs.popover' , function () { // practise something… }) Example alerts
Add dismiss functionality to all alert messages with this plugin.
When using a .close button, information technology must exist the outset child of the .alarm-dismissible and no text content may come earlier it in the markup.
Usage
Just add data-dismiss="alert" to your close push button to automatically give an alert close functionality. Closing an alert removes it from the DOM.
<button type= "push" class= "close" information-dismiss= "alert" aria-label= "Shut" > <span aria-hidden= "true" > × </span> </button> To have your alerts use animation when closing, make certain they take the .fade and .in classes already applied to them.
Methods
$().alert()
Makes an alert mind for click events on descendant elements which accept the data-dismiss="alarm" attribute. (Non necessary when using the data-api'south auto-initialization.)
$().alert('close')
Closes an alert past removing information technology from the DOM. If the .fade and .in classes are present on the element, the alert will fade out before it is removed.
Events
Bootstrap's alarm plugin exposes a few events for hooking into alert functionality.
| Result Type | Description |
|---|---|
| shut.bs.alert | This event fires immediately when the shut example method is called. |
| closed.bs.alert | This effect is fired when the alert has been closed (will expect for CSS transitions to complete). |
$ ( '#myAlert' ). on ( 'closed.bs.warning' , office () { // practise something… }) Exercise more with buttons. Control button states or create groups of buttons for more components like toolbars.
Stateful
Add data-loading-text="Loading..." to use a loading country on a push button.
This characteristic is deprecated since v3.3.5 and has been removed in v4.
Utilise whichever state you like!
For the sake of this sit-in, we are using data-loading-text and $().push('loading'), but that's not the but state you lot can apply. See more on this below in the $().button(string) documentation.
<button type= "button" id= "myButton" data-loading-text= "Loading..." class= "btn btn-primary" autocomplete= "off" > Loading state </button> <script> $ ( '#myButton' ). on ( 'click' , office () { var $btn = $ ( this ). button ( 'loading' ) // business logic... $btn . button ( 'reset' ) }) </script> Single toggle
Add data-toggle="push button" to activate toggling on a single button.
Pre-toggled buttons demand .active and aria-pressed="truthful"
For pre-toggled buttons, yous must add the .active class and the aria-pressed="true" attribute to the push button yourself.
<button type= "button" class= "btn btn-primary" data-toggle= "button" aria-pressed= "simulated" autocomplete= "off" > Single toggle </button> Checkbox / Radio
Add together data-toggle="buttons" to a .btn-group containing checkbox or radio inputs to enable toggling in their corresponding styles.
Preselected options demand .active
For preselected options, you lot must add the .active class to the input'southward label yourself.
Visual checked state only updated on click
If the checked land of a checkbox push is updated without firing a click event on the button (eastward.g. via <input type="reset"> or via setting the checked holding of the input), you will demand to toggle the .active class on the input's label yourself.
<div course= "btn-grouping" data-toggle= "buttons" > <label class= "btn btn-main active" > <input type= "checkbox" autocomplete= "off" checked > Checkbox 1 (pre-checked) </characterization> <label class= "btn btn-primary" > <input blazon= "checkbox" autocomplete= "off" > Checkbox 2 </label> <label class= "btn btn-primary" > <input type= "checkbox" autocomplete= "off" > Checkbox 3 </label> </div>
<div class= "btn-grouping" data-toggle= "buttons" > <label class= "btn btn-chief agile" > <input blazon= "radio" name= "options" id= "option1" autocomplete= "off" checked > Radio ane (preselected) </label> <characterization grade= "btn btn-primary" > <input type= "radio" proper noun= "options" id= "option2" autocomplete= "off" > Radio two </label> <label class= "btn btn-main" > <input blazon= "radio" name= "options" id= "option3" autocomplete= "off" > Radio three </label> </div> Methods
$().button('toggle')
Toggles button land. Gives the button the appearance that it has been activated.
$().button('reset')
Resets push button country - swaps text to original text. This method is asynchronous and returns before the resetting has actually completed.
$().button(cord)
Swaps text to whatever information divers text state.
<button type= "push button" id= "myStateButton" information-complete-text= "finished!" class= "btn btn-principal" autocomplete= "off" > ... </button> <script> $ ( '#myStateButton' ). on ( 'click' , role () { $ ( this ). button ( 'complete' ) // button text will exist "finished!" }) </script> Flexible plugin that utilizes a handful of classes for piece of cake toggle behavior.
Plugin dependency
Collapse requires the transitions plugin to be included in your version of Bootstrap.
Case
Click the buttons below to show and hibernate another element via class changes:
-
.collapsehides content -
.collapsingis applied during transitions -
.collapse.inshows content
You can utilise a link with the href aspect, or a button with the data-target aspect. In both cases, the data-toggle="collapse" is required.
Link with href
Anim pariatur cliché reprehenderit, enim eiusmod high life accusamus terry richardson advertizement squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
<a class= "btn btn-main" role= "push button" data-toggle= "plummet" href= "#collapseExample" aria-expanded= "faux" aria-controls= "collapseExample" > Link with href </a> <button class= "btn btn-primary" blazon= "button" data-toggle= "plummet" information-target= "#collapseExample" aria-expanded= "false" aria-controls= "collapseExample" > Button with data-target </button> <div class= "collapse" id= "collapseExample" > <div class= "well" > ... </div> </div> Accordion instance
Extend the default plummet beliefs to create an accordion with the console component.
Collapsible Group Particular #i
Anim pariatur cliche reprehenderit, enim eiusmod loftier life accusamus terry richardson ad squid. 3 wolf moon officia aute, not cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch iii wolf moon tempor, sunt aliqua put a bird on it squid single-origin java nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Advertisement vegan excepteur butcher vice lomo. Leggings occaecat craft beer subcontract-to-tabular array, raw denim aesthetic synth nesciunt you probably oasis't heard of them accusamus labore sustainable VHS.
Collapsible Group Item #2
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson advertizement squid. iii wolf moon officia aute, not cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch iii wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt y'all probably haven't heard of them accusamus labore sustainable VHS.
Collapsible Group Detail #3
Anim pariatur cliche reprehenderit, enim eiusmod loftier life accusamus terry richardson advertizement squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat arts and crafts beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
<div class= "panel-group" id= "squeeze box" role= "tablist" aria-multiselectable= "true" > <div grade= "console console-default" > <div class= "panel-heading" role= "tab" id= "headingOne" > <h4 class= "console-title" > <a role= "push button" data-toggle= "collapse" information-parent= "#accordion" href= "#collapseOne" aria-expanded= "true" aria-controls= "collapseOne" > Collapsible Group Item #i </a> </h4> </div> <div id= "collapseOne" class= "panel-collapse collapse in" role= "tabpanel" aria-labelledby= "headingOne" > <div course= "panel-body" > Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson advertizement squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin java nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat arts and crafts beer farm-to-table, raw denim aesthetic synth nesciunt yous probably haven't heard of them accusamus labore sustainable VHS. </div> </div> </div> <div class= "panel panel-default" > <div course= "panel-heading" role= "tab" id= "headingTwo" > <h4 class= "console-title" > <a class= "complanate" part= "push button" information-toggle= "collapse" data-parent= "#accordion" href= "#collapseTwo" aria-expanded= "false" aria-controls= "collapseTwo" > Collapsible Grouping Item #2 </a> </h4> </div> <div id= "collapseTwo" class= "console-plummet plummet" role= "tabpanel" aria-labelledby= "headingTwo" > <div class= "console-trunk" > Anim pariatur cliché reprehenderit, enim eiusmod loftier life accusamus terry richardson advertizing squid. iii wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer subcontract-to-tabular array, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. </div> </div> </div> <div grade= "panel panel-default" > <div form= "console-heading" function= "tab" id= "headingThree" > <h4 class= "console-title" > <a class= "collapsed" function= "button" data-toggle= "collapse" data-parent= "#accordion" href= "#collapseThree" aria-expanded= "imitation" aria-controls= "collapseThree" > Collapsible Grouping Item #3 </a> </h4> </div> <div id= "collapseThree" class= "panel-plummet plummet" function= "tabpanel" aria-labelledby= "headingThree" > <div course= "panel-torso" > Anim pariatur cliché reprehenderit, enim eiusmod high life accusamus terry richardson advertising squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin java nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. </div> </div> </div> </div> It's likewise possible to bandy out .panel-torsos with .list-groups.
Collapsible list grouping
- Bootply
- One itmus air-conditioning facilin
- Second eros
Make expand/collapse controls accessible
Be certain to add aria-expanded to the control element. This attribute explicitly defines the current state of the collapsible chemical element to screen readers and similar assistive technologies. If the collapsible element is closed by default, it should have a value of aria-expanded="false". If you've set the collapsible element to be open by default using the in form, set aria-expanded="true" on the command instead. The plugin will automatically toggle this attribute based on whether or non the collapsible element has been opened or closed.
Additionally, if your control chemical element is targeting a single collapsible element – i.e. the information-target aspect is pointing to an id selector – you may add an additional aria-controls attribute to the command element, containing the id of the collapsible chemical element. Modern screen readers and similar assistive technologies brand use of this attribute to provide users with boosted shortcuts to navigate direct to the collapsible element itself.
Usage
The plummet plugin utilizes a few classes to handle the heavy lifting:
-
.collapsehides the content -
.plummet.inshows the content -
.collapsingis added when the transition starts, and removed when it finishes
These classes can be found in component-animations.less.
Via data attributes
Just add data-toggle="collapse" and a data-target to the element to automatically assign control of a collapsible element. The information-target attribute accepts a CSS selector to apply the collapse to. Exist certain to add the course collapse to the collapsible element. If you'd similar information technology to default open, add together the additional grade in.
To add accordion-similar group management to a collapsible control, add the data attribute data-parent="#selector". Refer to the demo to encounter this in activeness.
Via JavaScript
Enable manually with:
$ ( '.plummet' ). collapse () Options
Options can exist passed via data attributes or JavaScript. For data attributes, suspend the option proper name to data-, equally in data-parent="".
| Name | type | default | description |
|---|---|---|---|
| parent | selector | false | If a selector is provided, and so all collapsible elements under the specified parent volition be closed when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the console class) |
| toggle | boolean | truthful | Toggles the collapsible chemical element on invocation |
Methods
.collapse(options)
Activates your content equally a collapsible element. Accepts an optional options object.
$ ( '#myCollapsible' ). collapse ({ toggle : false }) .collapse('toggle')
Toggles a collapsible element to shown or subconscious. Returns to the caller before the collapsible element has actually been shown or hidden (i.e. earlier the shown.bs.collapse or subconscious.bs.collapse issue occurs).
.collapse('show')
Shows a collapsible element. Returns to the caller before the collapsible element has actually been shown (i.eastward. before the shown.bs.collapse issue occurs).
.collapse('hide')
Hides a collapsible chemical element. Returns to the caller before the collapsible element has actually been hidden (i.e. before the hidden.bs.collapse event occurs).
Events
Bootstrap's collapse class exposes a few events for hooking into plummet functionality.
| Result Type | Description |
|---|---|
| show.bs.collapse | This consequence fires immediately when the show instance method is called. |
| shown.bs.collapse | This effect is fired when a collapse chemical element has been made visible to the user (will wait for CSS transitions to complete). |
| hide.bs.collapse | This outcome is fired immediately when the hide method has been called. |
| subconscious.bs.collapse | This event is fired when a plummet element has been hidden from the user (volition expect for CSS transitions to consummate). |
$ ( '#myCollapsible' ). on ( 'subconscious.bs.collapse' , function () { // do something… }) A slideshow component for cycling through elements, like a carousel. Nested carousels are not supported.
Examples
<div id= "carousel-instance-generic" class= "carousel slide" data-ride= "carousel" > <!-- Indicators --> <ol class= "carousel-indicators" > <li data-target= "#carousel-example-generic" data-slide-to= "0" class= "active" ></li> <li data-target= "#carousel-example-generic" data-slide-to= "one" ></li> <li data-target= "#carousel-instance-generic" data-slide-to= "ii" ></li> </ol> <!-- Wrapper for slides --> <div class= "carousel-inner" office= "listbox" > <div class= "item active" > <img src= "..." alt= "..." > <div class= "carousel-caption" > ... </div> </div> <div class= "detail" > <img src= "..." alt= "..." > <div grade= "carousel-explanation" > ... </div> </div> ... </div> <!-- Controls --> <a form= "left carousel-control" href= "#carousel-instance-generic" part= "button" data-slide= "prev" > <bridge class= "glyphicon glyphicon-chevron-left" aria-subconscious= "true" ></bridge> <span form= "sr-only" >Previous</span> </a> <a class= "right carousel-command" href= "#carousel-example-generic" role= "push" data-slide= "next" > <span class= "glyphicon glyphicon-chevron-correct" aria-hidden= "true" ></span> <span class= "sr-just" >Next</span> </a> </div> Accessibility result
The carousel component is generally not compliant with accessibility standards. If you need to exist compliant, please consider other options for presenting your content.
Transition animations non supported in Cyberspace Explorer eight & nine
Bootstrap exclusively uses CSS3 for its animations, only Internet Explorer eight & 9 don't support the necessary CSS properties. Thus, there are no slide transition animations when using these browsers. Nosotros have intentionally decided not to include jQuery-based fallbacks for the transitions.
Initial active chemical element required
The .active class needs to be added to one of the slides. Otherwise, the carousel will not be visible.
Glyphicon icons not necessary
The .glyphicon .glyphicon-chevron-left and .glyphicon .glyphicon-chevron-right classes are not necessarily needed for the controls. Bootstrap provides .icon-prev and .icon-adjacent as plain unicode alternatives.
Optional captions
Add captions to your slides easily with the .carousel-caption element within any .detail. Place but about whatever optional HTML within there and it volition be automatically aligned and formatted.
Showtime slide characterization
Nulla vitae elit libero, a pharetra augue mollis interdum.
2d slide label
Lorem ipsum dolor sit down amet, consectetur adipiscing elit.
Third slide label
Praesent commodo cursus magna, vel scelerisque nisl consectetur.
Previous Next
<div grade= "item" > <img src= "..." alt= "..." > <div class= "carousel-caption" > <h3>...</h3> <p>...</p> </div> </div> Usage
Multiple carousels
Carousels require the use of an id on the outermost container (the .carousel) for carousel controls to function properly. When adding multiple carousels, or when changing a carousel'southward id, be sure to update the relevant controls.
Via information attributes
Use data attributes to easily command the position of the carousel. information-slide accepts the keywords prev or next, which alters the slide position relative to its current position. Alternatively, use information-slide-to to pass a raw slide index to the carousel data-slide-to="2", which shifts the slide position to a particular alphabetize starting time with 0.
The data-ride="carousel" aspect is used to mark a carousel as animative starting at folio load. It cannot be used in combination with (redundant and unnecessary) explicit JavaScript initialization of the same carousel.
Via JavaScript
Call carousel manually with:
$ ( '.carousel' ). carousel () Options
Options can be passed via information attributes or JavaScript. For data attributes, append the option proper name to data-, as in information-interval="".
| Proper noun | blazon | default | clarification |
|---|---|---|---|
| interval | number | 5000 | The corporeality of time to delay between automatically cycling an detail. If simulated, carousel volition not automatically cycle. |
| intermission | cord | nix | "hover" | If set to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If set to null, hovering over the carousel won't pause it. |
| wrap | boolean | true | Whether the carousel should cycle continuously or accept hard stops. |
| keyboard | boolean | truthful | Whether the carousel should react to keyboard events. |
Methods
.carousel(options)
Initializes the carousel with an optional options object and starts cycling through items.
$ ( '.carousel' ). carousel ({ interval : 2000 }) .carousel('bike')
Cycles through the carousel items from left to right.
.carousel('pause')
Stops the carousel from cycling through items.
.carousel(number)
Cycles the carousel to a item frame (0 based, like to an assortment).
.carousel('prev')
Cycles to the previous particular.
.carousel('next')
Cycles to the next item.
Events
Bootstrap's carousel class exposes two events for hooking into carousel functionality.
Both events have the following additional backdrop:
-
direction: The management in which the carousel is sliding (either"left"or"correct"). -
relatedTarget: The DOM element that is being slid into place as the active particular.
All carousel events are fired at the carousel itself (i.e. at the <div grade="carousel">).
| Outcome Type | Clarification |
|---|---|
| slide.bs.carousel | This issue fires immediately when the slide example method is invoked. |
| slid.bs.carousel | This effect is fired when the carousel has completed its slide transition. |
$ ( '#myCarousel' ). on ( 'slide.bs.carousel' , function () { // do something… }) Example
The affix plugin toggles position: fixed; on and off, emulating the consequence found with position: gluey;. The subnavigation on the correct is a alive demo of the braze plugin.
Usage
Use the affix plugin via data attributes or manually with your ain JavaScript. In both situations, you lot must provide CSS for the positioning and width of your affixed content.
Note: Do not utilise the affix plugin on an element contained in a relatively positioned element, such as a pulled or pushed column, due to a Safari rendering bug.
Positioning via CSS
The braze plugin toggles between iii classes, each representing a item state: .affix, .affix-meridian, and .braze-bottom. You lot must provide the styles, with the exception of position: fixed; on .braze, for these classes yourself (independent of this plugin) to handle the actual positions.
Here's how the braze plugin works:
- To start, the plugin adds
.braze-topto indicate the chemical element is in its top-most position. At this indicate no CSS positioning is required. - Scrolling past the element you desire affixed should trigger the actual affixing. This is where
.affixreplaces.affix-peakand setsposition: fixed;(provided by Bootstrap'south CSS). - If a bottom kickoff is divers, scrolling past it should replace
.brazewith.affix-bottom. Since offsets are optional, setting one requires yous to set the appropriate CSS. In this instance, addposition: absolute;when necessary. The plugin uses the data attribute or JavaScript option to determine where to position the element from at that place.
Follow the above steps to set your CSS for either of the usage options below.
Via data attributes
To hands add braze behavior to any element, simply add data-spy="braze" to the element you want to spy on. Utilize offsets to ascertain when to toggle the pinning of an element.
<div data-spy= "affix" information-outset-height= "60" data-get-go-bottom= "200" > ... </div> Via JavaScript
Call the braze plugin via JavaScript:
$ ( '#myAffix' ). affix ({ beginning : { pinnacle : 100 , bottom : function () { return ( this . bottom = $ ( '.footer' ). outerHeight ( truthful )) } } }) Options
Options can be passed via information attributes or JavaScript. For data attributes, suspend the pick proper noun to data-, as in information-start-top="200".
| Name | type | default | description |
|---|---|---|---|
| offset | number | function | object | 10 | Pixels to offset from screen when calculating position of roll. If a unmarried number is provided, the start will be practical in both top and bottom directions. To provide a unique, bottom and summit offset just provide an object offset: { tiptop: 10 } or outset: { top: 10, bottom: 5 }. Utilise a function when you need to dynamically calculate an offset. |
| target | selector | node | jQuery element | the window object | Specifies the target element of the affix. |
Methods
.braze(options)
Activates your content as affixed content. Accepts an optional options object.
$ ( '#myAffix' ). affix ({ showtime : 15 }) .braze('checkPosition')
Recalculates the state of the affix based on the dimensions, position, and scroll position of the relevant elements. The .affix, .braze-top, and .affix-bottom classes are added to or removed from the affixed content co-ordinate to the new country. This method needs to be chosen whenever the dimensions of the affixed content or the target element are changed, to ensure correct positioning of the affixed content.
$ ( '#myAffix' ). affix ( 'checkPosition' ) Events
Bootstrap'southward affix plugin exposes a few events for hooking into affix functionality.
| Event Type | Clarification |
|---|---|
| affix.bs.braze | This result fires immediately before the chemical element has been affixed. |
| affixed.bs.affix | This event is fired afterwards the element has been affixed. |
| affix-top.bs.affix | This event fires immediately earlier the element has been affixed-top. |
| affixed-elevation.bs.affix | This effect is fired later on the element has been affixed-top. |
| affix-lesser.bs.affix | This event fires immediately before the element has been affixed-bottom. |
| affixed-bottom.bs.affix | This outcome is fired after the element has been affixed-lesser. |
salernoandlegis79.blogspot.com
Source: https://getbootstrap.com/docs/3.3/javascript/
Post a Comment for "Close a Div and Do Not Show Again on Refresh"