Monday 1 February 2016

Ultra-light and simple Accordion With Jquery

Hello,
remember to include jQuery library before the javascript code below.
here is the code:
JS/Jquery:
if($('.faq-post').length){
        var self = $('.faq-body');
        $('.faq-body .faq-answer').hide();
        $('.faq-question').on('click',function(e){
            $('.faq-answer').hide();
            $(this).next().show();
            e.preventDefault();
            return false;
        });
    }
HTML:
<article class="col-xs-12">
<div class="faq-body">
<h5 class="faq-question"><a href="#" title="">Topic heading </a></h5>
<div class='faq-answer'>Content</div>
</div>
</article>
You can add you style as you wish.
Enjoy!!!

Follow me on twitter: http://www.twitter.com/_josiah_king Join me on Google+: https://www.plus.google.com/u/0/113541005774136102412/posts/p/pub?cfem=1

1 comment:

  1. This is the simplest jquery accordion script you can find on the web.

    ReplyDelete