HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
For a tutorial about Collapsibles, read our Bootstrap Collapse Tutorial
For a tutorial about Collapsibles, read our Bootstrap Collapse Tutorial.
Class | Description | Example |
---|---|---|
.collapse |
Hides the content | Try it |
.collapse show |
Shows the collapsible content by default | Try it |
.collapsing |
Added when the transition starts, and removed when it finishes | Try it |
Just add data-toggle="collapse"
and a data-target
to element to automatically
assign control of a collapsible element. The data-target attribute accepts a CSS
selector to apply the collapse to. Be sure to add the class collapse to the
collapsible element. If you'd like it to default open, add the additional class
"show".
<button class="btn" data-toggle="collapse" data-target="#demo">Collapsible</button>
<div id="demo" class="collapse">
Some text..
</div>
Enable manually with:
$('.collapse').collapse()
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-parent="".
Name | Type | Default | Description | Try it |
---|---|---|---|---|
parent | selector | false | All collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior) | Try it |
toggle | boolean | true | Toggles the collapsible element on invocation | Try it |
The following table lists all available collapse methods.
Method | Description | Try it |
---|---|---|
.collapse(options) | Activates the collapsible element with an option. See options above for valid values | |
.collapse("toggle") | Toggles the collapsible element | Try it |
.collapse("show") | Shows the collapsible element | Try it |
.collapse("hide") | Hides the collapsible element | Try it |
.collapse("dispose") | Destroys the collapsible element |
The following table lists all available collapse events.
Event | Description | Try it |
---|---|---|
show.bs.collapse | Occurs when the collapsible element is about to be shown | Try it |
shown.bs.collapse | Occurs when the collapsible element is fully shown (after CSS transitions have completed) | Try it |
hide.bs.collapse | Occurs when the collapsible element is about to be hidden | Try it |
hidden.bs.collapse | Occurs when the collapsible element is fully hidden (after CSS transitions have completed) | Try it |