Vanilla JavaScript accordion - accessible and super tiny (~400 bytes gzipped).
— Inspired by the blazing fast, lightweight, cross-platform and crazy popular Vanilla JS framework.
Option | Type | Default | Description |
---|---|---|---|
element | string or object | id of the accordion container or the DOM element | |
openTab | int | Accordion tab to start open with. If not defined all tabs closed. | |
oneOpen | boolean | false | Only one accordion tab can be open at a time. |
Method | Argument | Description |
---|---|---|
.close(index) | index: int | Closes the accordion tab by index |
.open(index) | index: int | Opens the accordion tab by index |
.destroy() | Removes the event listener |
var accordion = new Accordion({
element: 'accordion',
openTab: 2,
oneOpen: true
});
npm test
Browser | Support | Dependencies |
---|---|---|
Chrome | yes | - |
Firefox | yes | - |
Safari | yes | - |
Opera | yes | - |
IE | yes* | Polyfill for .classList in IE9 |
* IE9 and up
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.
See Unlicense for full details.