Available on GitHub
<script src="path/to/vanilla-js-accordion.min.js"></script>
<link rel="stylesheet" href="path/to/vanilla-js-accordion.css">
<div class="js-Accordion" id="accordion">
<button>Title 1</button>
<div>
Shabby chic ennui cred godard, forage roof party scenester health goth typewriter pitchfork. Stumptown whatever fap, austin heirloom asymmetrical lo-fi ethical seitan. Post-ironic hella listicle brunch meggings artisan. YOLO tattooed blue bottle, fanny pack gluten-free put a bird on it migas forage trust fund.
</div>
<button>Title 2</button>
<div>
Shabby chic ennui cred godard, forage roof party scenester health goth typewriter pitchfork. Stumptown whatever fap, austin heirloom asymmetrical lo-fi ethical seitan. Post-ironic hella listicle brunch meggings artisan. YOLO tattooed blue bottle, fanny pack gluten-free put a bird on it migas forage trust fund.
</div>
<button>Title 3</button>
<div>
Shabby chic ennui cred godard, forage roof party scenester health goth typewriter pitchfork. Stumptown whatever fap, austin heirloom asymmetrical lo-fi ethical seitan. Post-ironic hella listicle brunch meggings artisan. YOLO tattooed blue bottle, fanny pack gluten-free put a bird on it migas forage trust fund.
</div>
</div>
var accordion = new Accordion({
element: "accordion", // ID of the accordion container
openTab: 2, // [optional] Accordion tab to start opened with. All tabs closed if not set.
oneOpen: true // [optional] Allow one accordion tab only to be opened at a time
});
Option | Type | Default | Description |
---|---|---|---|
element | string | id of the accordion container | |
oneOpen | boolean | false | Only one tab can be open |
openTab | int | Start the accordion with this tab open |
Method | Arguments | Description |
---|---|---|
.open(n) | n: int | Opens an accordion tab by index |
.close(n) | n: int | Closes an accordion tab by index |
.destroy() | Removes the event listener from accordion |
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
For more information, please refer to http://unlicense.org