Lightweight jQuery Accordion / Toggle Control Plugin - rjAccordion
| File Size: | 12.2 KB |
|---|---|
| Views Total: | 2278 |
| Last Update: | |
| Publish Date: | |
| Official Website: | Go to website |
| License: | MIT |
rjAccordion is a jQuery accordion plugin which allows you to present collapsed content panels with smooth expand / collapse animations. Also provides a 'toggle' mode which allows you to expand multiple content panels at a time.
How to use it:
1. Create the accordion headers and panels as shown below:
<div class="accordion demo">
<div class="accordion-section">
<a class="accordion-section-header"
data-target="#accordion-1">Accordion #1</a>
<div id="accordion-1" class="accordion-section-content">
<p>Content 1</p>
</div>
</div>
<div class="accordion-section">
<a class="accordion-section-header"
data-target="#accordion-2">Accordion #2</a>
<div id="accordion-2" class="accordion-section-content">
<p>Content 2</p>
</div>
</div>
<div class="accordion-section">
<a class="accordion-section-header"
data-target="#accordion-3">Accordion #3</a>
<div id="accordion-3" class="accordion-section-content">
<p>Content 3</p>
</div>
</div>
</div>
2. Include the jQuery rjAccordion plugin after jQuery javascript library but before the closing body tag.
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script src="path/to/rjAccordion.js"></script>
3. Initialize the accordion control by calling the function on the top container.
$(".demo").rjAccordion();
4. Add your own CSS styles to the accordion.
.accordion, .accordion * {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.accordion {
overflow: hidden;
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25);
border-radius: 3px;
background: #FC6D58;
color: #fff;
margin: 20px;
width: 60%;
}
.accordion-section-header {
width: 100%;
padding: 15px;
display: inline-block;
border-bottom: 1px solid #C0392B;
background: #E74C3C;
transition: all linear 0.15s;
font-size: 1.200em;
color: #fff;
}
.accordion-section-header.active, .accordion-section-header:hover {
background: #DA4453;
text-decoration: none;
}
.accordion-section:last-child .accordion-section-header { border-bottom: none; }
.accordion-section-content {
padding: 15px;
display: none;
}
5. Config the accordion plugin.
$(".demo").rjAccordion({
// animation speed in ms
transition_delay: 300,
// true = diable the toggle mode
toggle: true
});
This awesome jQuery plugin is developed by RajaJaganathan. For more Advanced Usages, please check the demo page or visit the official website.











