If Button Is Clicked Dont Do Action Again Jquery
JavaScript
Bring Bootstrap's components to life with over a dozen custom jQuery plugins. Easily include them all, or one past 1.
Individual or compiled
Plugins tin be included individually (using Bootstrap'south 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
comprise all plugins in a single file. Include only one.
Plugin dependencies
Some plugins and CSS components depend on other plugins. If y'all include plugins individually, brand sure to check for these dependencies in the docs. Likewise notation that all plugins depend on jQuery (this ways jQuery must be included earlier the plugin files). Consult our bower.json
to come across which versions of jQuery are supported.
Data attributes
Y'all tin utilize all Bootstrap plugins purely through the markup API without writing a unmarried line of JavaScript. This is Bootstrap'southward first-course API and should be your first consideration when using a plugin.
That said, in some situations it may exist desirable to turn this functionality off. Therefore, we besides provide the ability to disable the data attribute API by unbinding all events on the document namespaced with data-api
. This looks like this:
Alternatively, to target a specific plugin, only include the plugin's name as a namespace along with the data-api namespace like this:
Only one plugin per element via data attributes
Don't use data attributes from multiple plugins on the aforementioned chemical element. For case, a button cannot both have a tooltip and toggle a modal. To accomplish this, utilise a wrapping chemical element.
Programmatic API
We also believe y'all should be able to utilize all Bootstrap plugins purely through the JavaScript API. All public APIs are unmarried, chainable methods, and return the collection acted upon.
All methods should have an optional options object, a cord which targets a particular method, or cypher (which initiates a plugin with default behavior):
Each plugin likewise exposes its raw constructor on a Constructor
property: $.fn.popover.Constructor
. If y'all'd similar to get a item plugin instance, retrieve it directly from an element: $('[rel="popover"]').data('popover')
.
Default settings
You lot can change the default settings for a plugin by modifying the plugin's Constructor.DEFAULTS
object:
No conflict
Sometimes information technology is necessary to utilise 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 y'all wish to revert the value of.
Events
Bootstrap provides custom events for most plugins' unique actions. Mostly, these come in an infinitive and past participle form - where the infinitive (ex. show
) is triggered at the start of an upshot, and its by participle form (ex. shown
) is triggered on the completion of an activity.
As of 3.0.0, all Bootstrap events are namespaced.
All infinitive events provide preventDefault
functionality. This provides the ability to stop the execution of an action before it starts.
Sanitizer
Tooltips and Popovers utilize our built-in sanitizer to sanitize options which accept HTML.
The default whiteList
value is the post-obit:
If yous want to add together new values to this default whiteList
you tin do the following:
If you want to bypass our sanitizer because you prefer to use a dedicated library, for example DOMPurify, you should practice the following:
Browsers without document.implementation.createHTMLDocument
In instance of browsers that don't support document.implementation.createHTMLDocument
, like Internet Explorer eight, the built-in sanitize function returns the HTML as is.
If yous want to perform sanitization in this instance, delight specify sanitizeFn
and apply an external library like DOMPurify.
Version numbers
The version of each of Bootstrap's jQuery plugins tin can be accessed via the VERSION
holding of the plugin'southward constructor. For example, for the tooltip plugin:
No special fallbacks when JavaScript is disabled
Bootstrap's plugins don't autumn back specially gracefully when JavaScript is disabled. If yous care nearly the user experience in this case, utilize <noscript>
to explain the state of affairs (and how to re-enable JavaScript) to your users, and/or add your ain custom fallbacks.
Third-political party libraries
Bootstrap does not officially support third-party JavaScript libraries similar Paradigm or jQuery UI. Despite .noConflict
and namespaced events, there may exist compatibility problems that you demand to fix on your own.
About transitions
For simple transition effects, include transition.js
in one case alongside the other JS files. If y'all're using the compiled (or minified) bootstrap.js
, there is no need to include this—it'due south already in that location.
What'south inside
Transition.js is a basic helper for transitionEnd
events also as a CSS transition emulator. It's used by the other plugins to check 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
, equally the case may be) has loaded:
Modals are streamlined, but flexible, dialog prompts with the minimum required functionality and smart defaults.
Multiple open up modals non supported
Be sure not to open up a modal while another is withal visible. Showing more than one modal at a fourth dimension requires custom code.
Modal markup placement
Always try to place a modal's HTML code in a top-level position in your document to avoid other components affecting the modal's advent and/or functionality.
Due to how HTML5 defines its semantics, the autofocus
HTML attribute has no effect in Bootstrap modals. To achieve the same outcome, use some custom JavaScript:
Examples
Static example
A rendered modal with header, body, and set of actions in the footer.
Live demo
Toggle a modal via JavaScript by clicking the button beneath. It volition slide down and fade in from the meridian of the folio.
Make modals accessible
Be sure to add role="dialog"
and aria-labelledby="..."
, referencing the modal championship, to .modal
, and role="certificate"
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 mail service for more information.
Optional sizes
Modals take 2 optional sizes, available via modifier classes to be placed on a .modal-dialog
.
Remove animation
For modals that just announced rather than fade in to view, remove the .fade
class from your modal markup.
Using the grid system
To have advantage of the Bootstrap filigree organisation inside a modal, just nest .row
s inside the .modal-body
and so apply the normal grid system classes.
Take a bunch of buttons that all trigger the aforementioned modal, merely with slightly different contents? Apply event.relatedTarget
and HTML information-*
attributes (perchance via jQuery) to vary the contents of the modal depending on which push button was clicked. Run across the Modal Events docs for details on relatedTarget
,
Usage
The modal plugin toggles your subconscious content on demand, via data attributes or JavaScript. It also adds .modal-open
to the <body>
to override default scrolling behavior and generates a .modal-properties
to provide a click area for dismissing shown modals when clicking outside the modal.
Via information attributes
Activate a modal without writing JavaScript. Ready 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.
Via JavaScript
Call a modal with id myModal
with a single line of JavaScript:
Options
Options can exist passed via information attributes or JavaScript. For data attributes, append the choice name to data-
, equally in information-backdrop=""
.
Name | blazon | default | clarification |
---|---|---|---|
backdrop | boolean or the string 'static' | true | Includes a modal-properties chemical element. Alternatively, specify static for a properties which doesn't close the modal on click. |
keyboard | boolean | truthful | Closes the modal when escape key is pressed |
show | boolean | true | Shows the modal when initialized. |
remote | path | false | This option is deprecated since v3.3.0 and has been removed in v4. We recommend instead using client-side templating or a data binding framework, or calling jQuery.load yourself. If a remote URL is provided, content will be loaded 1 time via jQuery's |
Methods
.modal(options)
Activates your content every bit a modal. Accepts an optional options object
.
.modal('toggle')
Manually toggles a modal. Returns to the caller before the modal has actually been shown or subconscious (i.due east. before the shown.bs.modal
or hidden.bs.modal
result occurs).
.modal('testify')
Manually opens a modal. Returns to the caller before the modal has actually been shown (i.east. before the shown.bs.modal
event occurs).
.modal('hibernate')
Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.e. earlier the hidden.bs.modal
event occurs).
.modal('handleUpdate')
Readjusts the modal's positioning to counter a scrollbar in instance i should appear, which would make the modal leap to the left.
Only needed when the elevation of the modal changes while information technology is open.
Events
Bootstrap'due south modal class exposes a few events for hooking into modal functionality.
All modal events are fired at the modal itself (i.due east. at the <div class="modal">
).
Outcome Type | Description |
---|---|
show.bs.modal | This event fires immediately when the evidence instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the effect. |
shown.bs.modal | This event is fired when the modal has been made visible to the user (will look for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event. |
hide.bs.modal | This consequence is fired immediately when the hide instance method has been chosen. |
hidden.bs.modal | This event is fired when the modal has finished beingness hidden from the user (will wait for CSS transitions to consummate). |
loaded.bs.modal | This event is fired when the modal has loaded content using the remote option. |
Examples
Add together dropdown menus to nearly annihilation with this simple plugin, including the navbar, tabs, and pills.
Within a navbar
Within pills
Usage
Via data attributes or JavaScript, the dropdown plugin toggles subconscious content (dropdown menus) by toggling the .open
class on the parent list item.
On mobile devices, opening a dropdown adds a .dropdown-backdrop
equally a tap area for closing dropdown menus when tapping outside the menu, a requirement for proper iOS support. This means that switching from an open dropdown menu to a different dropdown carte du jour requires an actress tap on mobile.
Note: The data-toggle="dropdown"
attribute is relied on for closing dropdown menus at an application level, so it's a good thought to always use it.
Via data attributes
Add together information-toggle="dropdown"
to a link or push button to toggle a dropdown.
To continue URLs intact with link buttons, use the data-target
aspect instead of href="#"
.
Via JavaScript
Call the dropdowns via JavaScript:
data-toggle="dropdown"
notwithstanding required
Regardless of whether y'all call your dropdown via JavaScript or instead utilise the data-api, data-toggle="dropdown"
is always required to be 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-carte
's parent element.
All dropdown events take a relatedTarget
holding, whose value is the toggling anchor element.
Event Type | Description |
---|---|
show.bs.dropdown | This outcome fires immediately when the show instance method is called. |
shown.bs.dropdown | This event is fired when the dropdown has been fabricated visible to the user (will wait for CSS transitions, to complete). |
hide.bs.dropdown | This upshot is fired immediately when the hibernate instance method has been called. |
subconscious.bs.dropdown | This outcome is fired when the dropdown has finished existence hidden from the user (will wait for CSS transitions, to complete). |
The ScrollSpy plugin is for automatically updating nav targets based on scroll position. Scroll the surface area beneath the navbar and spotter the agile class change. The dropdown sub items will be highlighted as well.
Requires relative positioning
No matter the implementation method, scrollspy requires the use of position: relative;
on the element you're spying on. In most cases this is the <body>
. When scrollspying on elements other than the <body>
, be sure to accept a height
set and overflow-y: scroll;
practical.
Via information attributes
To hands add scrollspy behavior to your topbar navigation, add together data-spy="scroll"
to the element you want to spy on (near typically this would be the <torso>
). So add the data-target
attribute with the ID or class of the parent element of whatever Bootstrap .nav
component.
Via JavaScript
Later on adding position: relative;
in your CSS, call the scrollspy via JavaScript:
Methods
.scrollspy('refresh')
When using scrollspy in conjunction with calculation or removing of elements from the DOM, y'all'll need to phone call the refresh method like so:
Options
Options tin be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in information-get-go=""
.
Name | type | default | description |
---|---|---|---|
offset | number | ten | Pixels to kickoff from top when calculating position of coil. |
Events
Event Type | Description |
---|---|
activate.bs.scrollspy | This event fires whenever a new item becomes activated by the scrollspy. |
Example tabs
Add quick, dynamic tab functionality to transition through panes of local content, fifty-fifty via dropdown menus. Nested tabs are not supported.
Raw denim you lot probably oasis't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth principal cleanse. Mustache platitude 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.
Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin java squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table arts and crafts beer twee. Qui photograph booth letterpress, commodo enim craft 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-chip, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Fine art political party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-tabular array readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid eight-scrap cred pitchfork. Williamsburg banh mi whatever gluten-costless, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you lot probably haven't heard of them, vinyl craft beer weblog stumptown. Pitchfork sustainable tofu synth chambray yr.
Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art political party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche loftier life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-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 be activated individually):
Y'all can actuate individual tabs in several ways:
Markup
You can actuate a tab or pill navigation without writing whatsoever JavaScript past simply specifying data-toggle="tab"
or information-toggle="pill"
on an element. Calculation the nav
and nav-tabs
classes to the tab ul
will apply the Bootstrap tab styling, while calculation the nav
and nav-pills
classes will apply pill styling.
Fade event
To make tabs fade in, add .fade
to each .tab-pane
. The first tab pane must also have .in
to make the initial content visible.
Methods
$().tab
Activates a tab element and content container. Tab should take either a data-target
or an href
targeting a container node in the DOM. In the to a higher place examples, the tabs are the <a>
due south with information-toggle="tab"
attributes.
.tab('evidence')
Selects the given tab and shows its associated content. Whatever other tab that was previously selected becomes unselected and its associated content is hidden. Returns to the caller before the tab pane has actually been shown (i.e. before the shown.bs.tab
event occurs).
Events
When showing a new tab, the events fire in the following lodge:
-
hide.bs.tab
(on the current agile tab) -
testify.bs.tab
(on the to-be-shown tab) -
subconscious.bs.tab
(on the previous agile tab, the same one every bit for thehide.bs.tab
event) -
shown.bs.tab
(on the newly-active just-shown tab, the same one as for theshow.bs.tab
event)
If no tab was already active, so the hibernate.bs.tab
and subconscious.bs.tab
events volition not be fired.
Event Type | Description |
---|---|
show.bs.tab | This upshot fires on tab show, just before the new tab has been shown. Use event.target and outcome.relatedTarget to target the active tab and the previous active tab (if bachelor) respectively. |
shown.bs.tab | This event fires on tab evidence subsequently a tab has been shown. Use event.target and event.relatedTarget to target the agile tab and the previous active tab (if available) respectively. |
hide.bs.tab | This outcome fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use upshot.target and event.relatedTarget to target the electric current active tab and the new soon-to-be-active tab, respectively. |
subconscious.bs.tab | This upshot fires after a new tab is shown (and thus the previous active tab is hidden). Utilize event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively. |
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 haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney'southward fixie sustainable quinoa 8-bit american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan any keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.
Static tooltip
Four options are available: summit, right, lesser, and left aligned.
4 directions
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element.
Trigger the tooltip via JavaScript:
Markup
The required markup for a tooltip is only a data
aspect and title
on the HTML element you lot wish to have a tooltip. The generated markup of a tooltip is rather simple, though it does require a position (by default, set to top
past the plugin).
Options
Options can be passed via data attributes or JavaScript. For information attributes, append the option proper name to data-
, as in information-animation=""
.
Note that for security reasons the sanitize
, sanitizeFn
and whiteList
options cannot be supplied using data attributes.
Name | Type | Default | Description |
---|---|---|---|
animation | boolean | true | Utilise a CSS fade transition to the tooltip |
container | string | false | false | Appends the tooltip to a specific chemical element. Case: |
delay | number | object | 0 | Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type If a number is supplied, delay is applied to both hide/show Object construction is: |
html | boolean | false | Insert HTML into the tooltip. If false, jQuery's text method will exist used to insert content into the DOM. Use text if you're worried about XSS attacks. |
placement | string | office | 'top' | How to position the tooltip - top | bottom | left | correct | auto. When a function is used to decide the placement, it is chosen with the tooltip DOM node as its first argument and the triggering chemical element DOM node every bit its 2d. The |
selector | string | false | If a selector is provided, tooltip objects will be delegated to the specified targets. In do, this is used to also apply tooltips to dynamically added DOM elements (jQuery.on support). See this and an informative example. |
template | string | '<div class="tooltip" part="tooltip"><div form="tooltip-pointer"></div><div class="tooltip-inner"></div></div>' | Base HTML to use when creating the tooltip. The tooltip's The outermost wrapper element should have the |
title | cord | function | '' | Default title value if If a part is given, it will be chosen with its |
trigger | string | 'hover focus' | How tooltip is triggered - click | hover | focus | manual. You may laissez passer multiple triggers; separate them with a space. manual cannot be combined with any other trigger. |
viewport | string | object | function | { selector: 'body', padding: 0 } | Keeps the tooltip within the premises of this chemical element. Example: If a office is given, it is chosen with the triggering chemical element DOM node as its only argument. The |
sanitize | boolean | true | Enable or disable the sanitization. If activated 'template' , 'content' and 'championship' options will be sanitized. |
whiteList | object | Default value | Object which contains allowed attributes and tags |
sanitizeFn | zippo | function | nix | Here you can supply your own sanitize function. This tin exist useful if you prefer to use a dedicated library to perform sanitization. |
Methods
$().tooltip(options)
Attaches a tooltip handler to an element collection.
.tooltip('show')
Reveals an element's tooltip. Returns to the caller earlier the tooltip has actually been shown (i.e. before the shown.bs.tooltip
event occurs). This is considered a "transmission" triggering of the tooltip. Tooltips with zero-length titles are never displayed.
.tooltip('hide')
Hides an element's tooltip. Returns to the caller before the tooltip has really been hidden (i.east. before the hidden.bs.tooltip
effect occurs). This is considered a "manual" triggering of the tooltip.
.tooltip('toggle')
Toggles an element'south tooltip. Returns to the caller before the tooltip has actually been shown or subconscious (i.e. earlier the shown.bs.tooltip
or hidden.bs.tooltip
event occurs). This is considered a "manual" triggering of the tooltip.
.tooltip('destroy')
Hides and destroys an element's tooltip. Tooltips that utilize delegation (which are created using the selector
option) cannot be individually destroyed on descendant trigger elements.
Events
Event Type | Description |
---|---|
bear witness.bs.tooltip | This event fires immediately when the show instance method is called. |
shown.bs.tooltip | This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete). |
hide.bs.tooltip | This event is fired immediately when the hide instance method has been called. |
hidden.bs.tooltip | This effect is fired when the tooltip has finished being hidden from the user (volition wait for CSS transitions to complete). |
inserted.bs.tooltip | This event is fired after the show.bs.tooltip issue when the tooltip template has been added to the DOM. |
Add small overlays of content, like those on the iPad, to any 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 be to select them past their data-toggle
attribute:
Popovers in push button groups, input groups, and tables require special setting
When using popovers on elements within a .btn-group
or an .input-grouping
, or on table-related elements (<td>
, <th>
, <tr>
, <thead>
, <tbody>
, <tfoot>
), you lot'll take to specify the option container: 'trunk'
(documented below) to avert unwanted side effects (such as the element growing wider and/or losing its rounded corners when the popover is triggered).
Popovers on disabled elements require wrapper elements
To add together a popover to a disabled
or .disabled
chemical element, put the element within of a <div>
and utilise the popover to that <div>
instead.
Multiple-line links
Sometimes you desire to add a popover to a hyperlink that wraps multiple lines. The default behavior of the popover plugin is to center it horizontally and vertically. Add together white-infinite: nowrap;
to your anchors to avoid this.
Examples
Static popover
Four options are available: pinnacle, correct, bottom, and left aligned.
Popover superlative
Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Popover correct
Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Popover bottom
Sed posuere consectetur est at lobortis. Aenean european union 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
4 directions
Dismiss on next click
Utilise the focus
trigger to dismiss popovers on the next click that the user makes.
Specific markup required for dismiss-on-next-click
For proper cross-browser and cross-platform behavior, yous must use the <a>
tag, not the <push>
tag, and you also must include the part="push button"
and tabindex
attributes.
Usage
Enable popovers via JavaScript:
Options
Options can be passed via information attributes or JavaScript. For data attributes, append the option name to information-
, every bit in data-animation=""
.
Note that for security reasons the sanitize
, sanitizeFn
and whiteList
options cannot be supplied using data attributes.
Name | Type | Default | Description |
---|---|---|---|
animation | boolean | truthful | Apply a CSS fade transition to the popover |
container | string | simulated | false | Appends the popover to a specific element. Instance: |
content | string | function | '' | Default content value if If a function is given, it will be called with its |
delay | number | object | 0 | Filibuster showing and hiding the popover (ms) - does not apply to manual trigger type If a number is supplied, delay is applied to both hide/show Object structure is: |
html | boolean | false | Insert HTML into the popover. If faux, jQuery's text method volition be used to insert content into the DOM. Use text if you're worried near XSS attacks. |
placement | string | function | 'right' | How to position the popover - pinnacle | bottom | left | right | car. When a function is used to determine the placement, it is called with the popover DOM node as its first argument and the triggering element DOM node as its second. The |
selector | string | imitation | If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to take popovers added. See this and an informative example. |
template | string | '<div class="popover" function="tooltip"><div grade="arrow"></div><h3 grade="popover-title"></h3><div course="popover-content"></div></div>' | Base HTML to use when creating the popover. The popover'south The popover'due south The outermost wrapper chemical element should have the |
title | cord | function | '' | Default title value if If a office is given, information technology will be called with its |
trigger | string | 'click' | How popover is triggered - click | hover | focus | manual. Yous may pass multiple triggers; separate them with a space. transmission cannot be combined with any other trigger. |
viewport | cord | object | part | { selector: 'body', padding: 0 } | Keeps the popover within the bounds of this element. Example: If a function is given, it is called with the triggering element DOM node as its only argument. The |
sanitize | boolean | true | Enable or disable the sanitization. If activated 'template' , 'content' and 'title' options will be sanitized. |
whiteList | object | Default value | Object which contains allowed attributes and tags |
sanitizeFn | null | function | zilch | Here you tin supply your own sanitize function. This can be useful if yous prefer to use a dedicated library to perform sanitization. |
Data attributes for individual popovers
Options for private popovers can alternatively be specified through the utilise of data attributes, as explained higher up.
Methods
$().popover(options)
Initializes popovers for an chemical element drove.
.popover('bear witness')
Reveals an element's popover. Returns to the caller before the popover has actually been shown (i.e. before the shown.bs.popover
event occurs). This is considered a "manual" triggering of the popover. Popovers whose both title and content are zero-length are never displayed.
.popover('hide')
Hides an element's popover. Returns to the caller before the popover has actually been hidden (i.e. earlier the hidden.bs.popover
event occurs). This is considered a "manual" triggering of the popover.
.popover('toggle')
Toggles an chemical element's popover. Returns to the caller earlier the popover has actually been shown or hidden (i.e. before the shown.bs.popover
or hidden.bs.popover
event occurs). This is considered a "manual" triggering of the popover.
.popover('destroy')
Hides and destroys an element'due south popover. Popovers that utilise delegation (which are created using the selector
option) cannot be individually destroyed on descendant trigger elements.
Events
Effect Blazon | Clarification |
---|---|
show.bs.popover | This issue fires immediately when the testify instance method is called. |
shown.bs.popover | This consequence is fired when the popover has been made visible to the user (will wait for CSS transitions to consummate). |
hide.bs.popover | This outcome is fired immediately when the hide instance method has been called. |
hidden.bs.popover | This event is fired when the popover has finished being hidden from the user (will await for CSS transitions to consummate). |
inserted.bs.popover | This event is fired after the testify.bs.popover upshot when the popover template has been added to the DOM. |
Example alerts
Add dismiss functionality to all warning letters with this plugin.
When using a .close
button, it must be the first kid of the .alert-dismissible
and no text content may come up before information technology in the markup.
Usage
But add data-dismiss="alert"
to your close push button to automatically give an alert close functionality. Closing an alert removes it from the DOM.
To accept your alerts use animation when closing, make sure they have the .fade
and .in
classes already applied to them.
Methods
$().alert()
Makes an alarm listen for click events on descendant elements which have the data-dismiss="alarm"
attribute. (Not necessary when using the information-api's automobile-initialization.)
$().alert('shut')
Closes an alert by removing it 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'due south warning plugin exposes a few events for hooking into alert functionality.
Effect Type | Description |
---|---|
close.bs.alert | This consequence fires immediately when the shut instance method is chosen. |
airtight.bs.warning | This event is fired when the alarm has been airtight (will await for CSS transitions to consummate). |
Exercise more than with buttons. Control button states or create groups of buttons for more components like toolbars.
Stateful
Add information-loading-text="Loading..."
to use a loading state on a push.
This characteristic is deprecated since v3.3.5 and has been removed in v4.
Employ whichever state you like!
For the sake of this demonstration, we are using data-loading-text
and $().button('loading')
, but that's non the just state yous can use. Come across more on this below in the $().push(string)
documentation.
Single toggle
Add data-toggle="button"
to activate toggling on a single push.
Pre-toggled buttons need .agile
and aria-pressed="true"
For pre-toggled buttons, you lot must add the .active
class and the aria-pressed="true"
attribute to the button
yourself.
Checkbox / Radio
Add data-toggle="buttons"
to a .btn-group
containing checkbox or radio inputs to enable toggling in their respective styles.
Preselected options need .agile
For preselected options, you must add the .active
course to the input'south label
yourself.
Visual checked state only updated on click
If the checked country of a checkbox push button is updated without firing a click
event on the button (east.g. via <input type="reset">
or via setting the checked
property of the input), you will demand to toggle the .agile
class on the input'south label
yourself.
Methods
$().button('toggle')
Toggles push button state. Gives the button the appearance that information technology has been activated.
$().push('reset')
Resets button state - swaps text to original text. This method is asynchronous and returns before the resetting has actually completed.
$().button(string)
Swaps text to any data defined text state.
Flexible plugin that utilizes a scattering of classes for easy toggle behavior.
Plugin dependency
Collapse requires the transitions plugin to exist included in your version of Bootstrap.
Case
Click the buttons below to show and hibernate another element via class changes:
-
.plummet
hides content -
.collapsing
is applied during transitions -
.plummet.in
shows content
You can apply a link with the href
attribute, or a push button with the data-target
attribute. In both cases, the data-toggle="collapse"
is required.
Link with href
Anim pariatur platitude reprehenderit, enim eiusmod loftier life accusamus terry richardson advert squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
Accordion case
Extend the default plummet beliefs to create an accordion with the panel component.
Collapsible Group Item #i
Anim pariatur platitude reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. three 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. Advertising vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt y'all probably oasis't heard of them accusamus labore sustainable VHS.
Collapsible Group Item #two
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad 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 information technology 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 you probably haven't heard of them accusamus labore sustainable VHS.
Collapsible Grouping Item #3
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson advert 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. Advertising vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably oasis't heard of them accusamus labore sustainable VHS.
Information technology's also possible to swap out .panel-trunk
south with .list-grouping
s.
Collapsible list group
- Bootply
- Ane itmus air-conditioning facilin
- 2nd eros
Make expand/collapse controls accessible
Be certain to add aria-expanded
to the command chemical element. This attribute explicitly defines the current state of the collapsible element to screen readers and similar assistive technologies. If the collapsible chemical element is closed past default, information technology should take a value of aria-expanded="false"
. If you lot've set the collapsible chemical element to exist open by default using the in
class, set aria-expanded="true"
on the control instead. The plugin volition automatically toggle this attribute based on whether or non the collapsible chemical element has been opened or closed.
Additionally, if your control chemical element is targeting a single collapsible element – i.e. the data-target
attribute is pointing to an id
selector – you may add an boosted aria-controls
attribute to the control element, containing the id
of the collapsible element. Modern screen readers and like assistive technologies make use of this attribute to provide users with boosted shortcuts to navigate directly to the collapsible element itself.
Usage
The collapse plugin utilizes a few classes to handle the heavy lifting:
-
.collapse
hides the content -
.plummet.in
shows the content -
.collapsing
is added when the transition starts, and removed when information technology finishes
These classes tin be found in component-animations.less
.
Via data attributes
Simply add together data-toggle="collapse"
and a data-target
to the element to automatically assign control of a collapsible element. The data-target
attribute accepts a CSS selector to apply the collapse to. Exist sure to add together the class collapse
to the collapsible element. If you'd like it to default open, add the additional course in
.
To add accordion-like grouping management to a collapsible control, add the data attribute data-parent="#selector"
. Refer to the demo to run across this in activeness.
Via JavaScript
Enable manually with:
Options
Options can be passed via information attributes or JavaScript. For data attributes, append the pick name to data-
, equally in information-parent=""
.
Name | type | default | clarification |
---|---|---|---|
parent | selector | imitation | If a selector is provided, so all collapsible elements under the specified parent will be closed when this collapsible item is shown. (like to traditional accordion behavior - this is dependent on the console class) |
toggle | boolean | truthful | Toggles the collapsible element on invocation |
Methods
.collapse(options)
Activates your content as a collapsible element. Accepts an optional options object
.
.collapse('toggle')
Toggles a collapsible element to shown or hidden. Returns to the caller earlier the collapsible element has really been shown or hidden (i.east. before the shown.bs.plummet
or hidden.bs.plummet
issue occurs).
.collapse('evidence')
Shows a collapsible chemical element. Returns to the caller before the collapsible element has actually been shown (i.east. before the shown.bs.collapse
event occurs).
.collapse('hide')
Hides a collapsible element. Returns to the caller before the collapsible element has actually been hidden (i.due east. before the hidden.bs.collapse
event occurs).
Events
Bootstrap's plummet class exposes a few events for hooking into collapse functionality.
Event Blazon | Description |
---|---|
show.bs.collapse | This outcome fires immediately when the show example method is called. |
shown.bs.collapse | This consequence is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete). |
hide.bs.collapse | This issue is fired immediately when the hide method has been chosen. |
hidden.bs.collapse | This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to consummate). |
A slideshow component for cycling through elements, like a carousel. Nested carousels are non supported.
Examples
Accessibility outcome
The carousel component is generally non compliant with accessibility standards. If you need to be compliant, please consider other options for presenting your content.
Transition animations not supported in Internet Explorer 8 & ix
Bootstrap exclusively uses CSS3 for its animations, just Internet Explorer 8 & 9 don't support the necessary CSS backdrop. Thus, at that place are no slide transition animations when using these browsers. We have intentionally decided not to include jQuery-based fallbacks for the transitions.
Initial agile chemical element required
The .active
class needs to be added to one of the slides. Otherwise, the carousel will non be visible.
Glyphicon icons non 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-next
every bit plainly unicode alternatives.
Optional captions
Add together captions to your slides hands with the .carousel-caption
element within any .item
. Identify just nearly whatsoever optional HTML within there and it volition exist automatically aligned and formatted.
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's id
, exist sure to update the relevant controls.
Via data attributes
Utilize data attributes to easily control the position of the carousel. information-slide
accepts the keywords prev
or next
, which alters the slide position relative to its current position. Alternatively, employ data-slide-to
to pass a raw slide index to the carousel data-slide-to="two"
, which shifts the slide position to a particular index showtime with 0
.
The information-ride="carousel"
aspect is used to marking a carousel every bit animative starting at page load. It cannot be used in combination with (redundant and unnecessary) explicit JavaScript initialization of the aforementioned carousel.
Via JavaScript
Telephone call carousel manually with:
Options
Options tin can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-interval=""
.
Proper noun | type | default | description |
---|---|---|---|
interval | number | 5000 | The amount of time to delay between automatically cycling an item. If false, carousel will non automatically cycle. |
pause | string | zero | "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 nix , hovering over the carousel won't pause it. |
wrap | boolean | true | Whether the carousel should bike continuously or have hard stops. |
keyboard | boolean | true | 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('bike')
Cycles through the carousel items from left to right.
.carousel('intermission')
Stops the carousel from cycling through items.
.carousel(number)
Cycles the carousel to a item frame (0 based, similar to an array).
.carousel('prev')
Cycles to the previous item.
.carousel('next')
Cycles to the adjacent item.
Events
Bootstrap's carousel grade exposes 2 events for hooking into carousel functionality.
Both events have the post-obit additional backdrop:
-
management
: The direction in which the carousel is sliding (either"left"
or"right"
). -
relatedTarget
: The DOM element that is being slid into place as the active item.
All carousel events are fired at the carousel itself (i.e. at the <div grade="carousel">
).
Effect Blazon | Description |
---|---|
slide.bs.carousel | This event fires immediately when the slide instance method is invoked. |
slid.bs.carousel | This event is fired when the carousel has completed its slide transition. |
Example
The affix plugin toggles position: fixed;
on and off, emulating the consequence establish with position: pasty;
. The subnavigation on the right is a alive demo of the affix plugin.
Usage
Utilise the affix plugin via data attributes or manually with your own JavaScript. In both situations, yous must provide CSS for the positioning and width of your affixed content.
Annotation: Do not employ the braze plugin on an chemical element contained in a relatively positioned element, such as a pulled or pushed column, due to a Safari rendering problems.
Positioning via CSS
The affix plugin toggles between three classes, each representing a particular land: .affix
, .affix-elevation
, and .braze-bottom
. Y'all must provide the styles, with the exception of position: fixed;
on .affix
, for these classes yourself (independent of this plugin) to handle the bodily positions.
Here'south how the affix plugin works:
- To start, the plugin adds
.affix-top
to signal the chemical element is in its acme-almost position. At this point no CSS positioning is required. - Scrolling by the element you desire affixed should trigger the actual affixing. This is where
.affix
replaces.affix-elevation
and setsposition: stock-still;
(provided past Bootstrap's CSS). - If a bottom offset is defined, scrolling past it should replace
.braze
with.braze-bottom
. Since offsets are optional, setting one requires you to set the appropriate CSS. In this instance, addposition: absolute;
when necessary. The plugin uses the data attribute or JavaScript option to make up one's mind where to position the chemical element from there.
Follow the to a higher place steps to set your CSS for either of the usage options below.
Via data attributes
To hands add affix behavior to whatever chemical element, merely add information-spy="affix"
to the element you lot want to spy on. Use offsets to define when to toggle the pinning of an element.
Via JavaScript
Call the affix plugin via JavaScript:
Options
Options tin can be passed via data attributes or JavaScript. For data attributes, suspend the selection name to data-
, as in information-first-elevation="200"
.
Name | blazon | default | clarification |
---|---|---|---|
offset | number | function | object | 10 | Pixels to commencement from screen when calculating position of scroll. If a single number is provided, the showtime volition be applied in both top and bottom directions. To provide a unique, lesser and acme showtime just provide an object offset: { peak: ten } or offset: { top: x, bottom: 5 } . Use a function when you need to dynamically summate an outset. |
target | selector | node | jQuery element | the window object | Specifies the target chemical element of the braze. |
Methods
.affix(options)
Activates your content as affixed content. Accepts an optional options object
.
.affix('checkPosition')
Recalculates the state of the braze based on the dimensions, position, and scroll position of the relevant elements. The .braze
, .affix-pinnacle
, and .affix-lesser
classes are added to or removed from the affixed content according to the new land. This method needs to be called whenever the dimensions of the affixed content or the target element are changed, to ensure correct positioning of the affixed content.
Events
Bootstrap's braze plugin exposes a few events for hooking into affix functionality.
Effect Blazon | Description |
---|---|
affix.bs.affix | This event fires immediately before the element has been affixed. |
affixed.bs.affix | This event is fired after the element has been affixed. |
affix-summit.bs.affix | This event fires immediately before the element has been affixed-top. |
affixed-top.bs.affix | This upshot is fired after the chemical element has been affixed-top. |
affix-bottom.bs.braze | This outcome fires immediately earlier the chemical element has been affixed-bottom. |
affixed-bottom.bs.braze | This event is fired subsequently the element has been affixed-bottom. |
Source: https://getbootstrap.com/docs/3.4/javascript/
0 Response to "If Button Is Clicked Dont Do Action Again Jquery"
Postar um comentário