Skip to content

zoltantothcom/vanilla-js-accordion

Repository files navigation

Vanilla JavaScript accordion

Build Status Coverage Status Dependencies

Vanilla JavaScript accordion - accessible and super tiny (~400 bytes gzipped).

— Inspired by the blazing fast, lightweight, cross-platform and crazy popular Vanilla JS framework.

Demo

ACCORDION

Options

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.

Methods

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

Usage example

var accordion = new Accordion({
    element: 'accordion',
    openTab: 2,
    oneOpen: true
});

Running the tests

npm test

Browser support and dependencies

Browser Support Dependencies
Chrome yes -
Firefox yes -
Safari yes -
Opera yes -
IE yes* Polyfill for .classList in IE9

* IE9 and up

License

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.

Related

Releases

No releases published

Packages

No packages published