CollapseJs
Lightweight Vanilla Javascript Collapse No Need any Dependency.
It's Easy as 123, No Dependency, No Conflicts
Installation
npm i collapsejs --save-dev
or use cdn
and include this style
Concept
<!-- Default -->Header 1Body 1 Header 2Body 2 ...
if you have multiple collapse on one page you need to wrap like this
<!-- Collapse 1 --> Header 1 Body 1 Header 2 Body 2 <!-- Collapse 2 --> Header 1 Body 1 Header 2 Body 2
here is the javascript initialize code for multiple
container: '.collapse-1' container: '.collapse-2'
Quick Usage
<!-- Styles --> Header 1 Body 1 Header 2 Body 2 <!-- Scripts -->
Options
here is the default options list:
container: '' // collapse wrap id or class e.g. #collapse-1 or .collapse-1 header: '.collapse__header' // header class body: '.collapse__body' // body class closed: false // if true initially all bodies will be closed multiple: false // multiple collapse expand collapsible: false // if true and multiple false then single item also collapsible. defaultOpen: 1 // default open tab #
API
here is the example:
var collapse = // Call this for close all itemscollapse // Call this for open all itemscollapse
Browser compatibility
- Newest two browser versions of Chrome, Firefox, Safari and Edge
- IE 10 and IE 11
License
© 2018 Ahsan Abrar Released under the MIT LICENSE