Home

Awesome

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

OptionTypeDefaultDescription
elementstring or objectid of the accordion container or the DOM element
openTabintAccordion tab to start open with. If not defined all tabs closed.
oneOpenbooleanfalseOnly one accordion tab can be open at a time.

Methods

MethodArgumentDescription
.close(index)index: intCloses the accordion tab by index
.open(index)index: intOpens 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

BrowserSupportDependencies
Chromeyes-
Firefoxyes-
Safariyes-
Operayes-
IEyes*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