Simple Smooth FAQ Accordion with jQuery CSS FAQ Slider - Download Simple Smooth FAQ Accordion with jQuery and CSS - FAQ Slider

Download Simple Smooth FAQ Accordion with jQuery and CSS – FAQ Slider

Posted on

This time I will share jQuery Plugin and tutorial about Simple Smooth FAQ Accordion with jQuery and CSS – FAQ Slider, hope it will help you in programming stack.

Simple Smooth FAQ Accordion with jQuery CSS FAQ Slider - Download Simple Smooth FAQ Accordion with jQuery and CSS - FAQ Slider
File Size: 7.19 KB
Views Total: 35597
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

FAQ Slider is a minimal jQuery script which helps you create a FAQ interface with a smooth sliding animation that acts like a vertical accordion.

How to use it:

1. Create a FAQ interface from a list of frequently asked questions and answers.

01 <ul class="faq">
02  
03   <li class="q">
04     <img src="img/arrow.png">
05     Question 1
06   </li>
07   <li class="a">Answer 1</li>
08    
09   <li class="q">
10     <img src="img/arrow.png">
11     Question 2
12   </li>
13   <li class="a">Answer 2</li>
14  
15   <li class="q">
16     <img src="img/arrow.png">
17     Question 3
18   </li>
19   <li class="a">Answer 3</li>
20  
21 </ul>

2. Add your own CSS styles to the FAQ accordion.

01 .faq li { padding: 20px; }
02  
03 .faq li.q {
04   background: #4FC2E;
05   font-weight: bold;
06   font-size: 120%;
07   border-bottom: 1px #ddd solid;
08   cursor: pointer;
09 }
10  
11 .faq li.a {
12   background: #3BB0D6;
13   display: none;
14   color:#fff;
15 }

3. Include jQuery library at the bottom of your FAQ page.

1 <script src="//code.jquery.com/jquery-1.11.3.min.js"></script>

4. The core JavaScript to enable the FAQ accordion.

01 // Accordian Action
02 var action = 'click';
03 var speed = "500";
04  
05  
06 $(document).ready(function(){
07  
08 // Question handler
09   $('li.q').on(action, function(){
10  
11     // gets next element
12     // opens .a of selected question
13     $(this).next().slideToggle(speed)
14      
15     // selects all other answers and slides up any open answer
16     .siblings('li.a').slideUp();
17    
18     // Grab img from clicked question
19     var img = $(this).children('img');
20  
21     // remove Rotate class from all images except the active
22     $('img').not(img).removeClass('rotate');
23  
24     // toggle rotate class
25     img.toggleClass('rotate');
26  
27   });
28  
29 });

5. Don’t forget to add the following CSS3 snippet into your CSS. This will rotate the arrow icon as you toggle a FAQ panel.

1 .rotate {
2   -moz-transform: rotate(90deg);
3   -webkit-transform: rotate(90deg);
4   transform: rotate(90deg);
5 }

This awesome jQuery plugin is developed by jeffward01. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net