This time I will share jQuery Plugin and tutorial about Accessible Cross-browser Accordion Plugin For jQuery – QuickAccord, hope it will help you in programming stack.
QuickAccord is a simple, accessible, cross-browser jQuery accordion plugin which allows to show / hide sectioned content using CSS3 transitions.
How to use it:
1. Add accordion triggers and content panels to the webpage as follow:
04 |
< div id = "accordion1" class = "accordion-content collapsed" > |
09 |
< a href = "#accordion2" class = "accordion-trigger" data-accord-group = "group1" >Accordion 2</ a > |
10 |
< div id = "accordion2" class = "accordion-content collapsed" > |
15 |
< a href = "#accordion3" class = "accordion-trigger" data-accord-group = "group1" >Accordion 3</ a > |
16 |
< div id = "accordion3" class = "accordion-content collapsed" > |
2. The basic CSS for the accordion. Override or modify the styles as shown below and then insert them into your existing CSS file.
01 |
ul { list-style : none ; } |
05 |
-webkit-border-radius: 8px ; |
06 |
-moz-border-radius: 8px ; |
08 |
border : 3px solid #D0D0D0 ; |
13 |
text-transform : uppercase ; |
15 |
text-decoration : none ; |
19 |
background-color : #D0D0D0 ; |
25 |
.accordion-trigger:after { |
30 |
transform: translateY( -50% ); |
34 |
.accordion-trigger.expanded:after { content : "-" ; } |
36 |
.accordion-trigger.collapsed:after { content : "+" ; } |
40 |
-webkit-transition: height 0.25 s; |
41 |
-moz-transition: height 0.25 s; |
42 |
transition: height 0.25 s; |
43 |
box-sizing: border-box; |
44 |
-moz-box-sizing: border-box; |
45 |
-webkit-box-sizing: border-box; |
48 |
.accordion-content. expanded { height : auto ; } |
50 |
.accordion-content.collapsed { height : 0 ; } |
52 |
.accordion-content p { padding : 16px ; } |
3. Put jQuery library and the QuickAccord’s script at the bottom of the webpage.
1 |
< script src = "//code.jquery.com/jquery.min.js" ></ script > |
2 |
< script src = "js/QuickAccord.js" ></ script > |
4. Call the function QuickAccord()
on the accordion triggers and done.
1 |
$( ".accordion-trigger" ).QuickAccord(); |
5. API methods.
01 |
var myAccordion = $( ".accordion-trigger" ).QuickAccord(); |
04 |
qa.QuickAccord.destroy(); |
07 |
myAccordion.QuickAccord.toggle(); |
10 |
myAccordion.QuickAccord.collapse(); |
13 |
myAccordion.QuickAccord.expand(); |
16 |
myAccordion.QuickAccord.isExpanded(); |
This awesome jQuery plugin is developed by koga73. For more Advanced Usages, please check the demo page or visit the official website.