This time I will share jQuery Plugin and tutorial about Minimal Accordion/Sliding Box Plugin – Accordion.js, hope it will help you in programming stack.
A minimal accordion engine written in jQuery that enables the users to collapse and expand sectioned content just like a sliding box.
The plugin simply provides a basic accordion logic to your sectioned content. Feel free to apply custom styles & animations to the accordion panels using your own CSS.
How to use it:
1. Add accordion headers (controls) and panels to the accordion interface as follows:
01 |
< div id = "my-accordion" class = "accordion" > |
11 |
< a class = "control" href = "#" >Accordion #2 < span class = "expand" >▼</ span >< span class = "collapse" >▲</ span ></ a > |
19 |
< a class = "control" href = "#" >Accordion #3 < span class = "expand" >▼</ span >< span class = "collapse" >▲</ span ></ a > |
2. Add jQuery JavaScript library and the Accordion.js script to the webpage.
1 |
< script src = "/path/to/cdn/jquery.min.js" ></ script > |
2 |
< script src = "/path/to/js/accordion.js" ></ script > |
3. Initailize the accordion plugin and done.
2 |
$( '#my-accordion' ).accordion(); |
4. Enable the smooth slide up/down animations. Default: false.
2 |
$( '#my-accordion' ).accordion({ |
5. Determine whether to allow multiple accordion panels to be expanded at a time. Default: false.
2 |
$( '#my-accordion' ).accordion({ |
6. Customize the appearance of the accordion with CSS.
02 |
border-bottom : 1px solid #9a9a9a ; |
07 |
text-decoration : none ; |
14 |
background-color : #f5f5f5 ; |
15 |
background-image : -moz-linear-gradient( top , #ffffff , #e6e6e6 ); |
16 |
background-image : -webkit-gradient(linear, 0 0 , 0 100% , from( #ffffff ), to( #e6e6e6 )); |
17 |
background-image : -webkit-linear-gradient( top , #ffffff , #e6e6e6 ); |
18 |
background-image : -o-linear-gradient( top , #ffffff , #e6e6e6 ); |
19 |
background-image : linear-gradient(to bottom , #ffffff , #e6e6e6 ); |
20 |
background-repeat : repeat-x ; |
21 |
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr= '#ffffffff' , endColorstr= '#ffe6e6e6' , GradientType= 0 ); |
22 |
filter: progid: DXImageTransform.Microsoft.gradient(enabled=false); |
25 |
.accordion .control . collapse { |
31 |
.accordion .control .expand { |
37 |
.accordion .control i { |