LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » HTML-CSS-PHP-JavaScript / JavaScript Codes » Simple And Clean FAQ Accordion JQuery Widget

Simple And Clean FAQ Accordion JQuery Widget

Simple-And-Clean-FAQ-Accordion-JQuery-Widget
FAQ and accordion are similar types of content having multiple sections in a single element. Each section contains a heading and body to add details. The only difference between these two widgets is that FAQ allows only text content while accordion allows any type of content. In this article let us discuss how to add an FAQ widget to any custom site.

There are many code snippets available online or on many other blogs and websites but everyone is not able to optimize your blog or website so you need some optimized code snippets. So now checkout out the code snippet for your blog and website that will give you all features for your desired code. Now grab the ready-to-use code and paste it where you want.

Features:

  1. Light Weight.
  2. JQuery Code.
  3. Cross Browser.
  4. Multi-Open In One Click.
  5. Fully Customizable.
  6. Responsive.

How To Create Simple And Clean FAQ Accordion JQuery Widget?

There are a few easy and understandable steps to achieve your desired functionality that we are gonna share below. Follow each step perfectly.

Recommended For You:
Simple And Clean Double Value CSS Badges And Labels Examples

JavaScript:

<script type='text/javascript' src='https://code.jquery.com/jquery-3.6.0.min.js' ></script>
<script>
jQuery(function() {
var $ = jQuery;
var faqTitle = $( ".faq h3" );
var answerFaq = $(".response");
faqTitle.click(function(e) {
e.preventDefault();
$(this).toggleClass('titleopen').next().slideToggle().toggleClass('open-close');
});
$( "#showall" ).click(function(e) {
e.preventDefault();
faqTitle.addClass('titleopen');
answerFaq.slideDown().addClass('open-close');
});
$( "#hideall" ).click(function(e) {
e.preventDefault();
faqTitle.removeClass('titleopen');
answerFaq.slideUp().removeClass('open-close');
});
});
</script>

CSS:

<style>
.faq_container{
background: #f5f5f5;
padding: 20px;
border: 1px solid #e5e5e5;
border-radius: 10px;
}

#show_hide_wrap{
text-align: right;
}

#show_hide_wrap p{
font-size: 16px;
}

#showall, #hideall{
display: inline-block;
background: #fff;
border: 2px solid rgba(86, 77, 77, 0.18);
padding: 5px 5px;
line-height: 1.5;
margin-bottom: 20px;
font-weight: bold !important;
height: 25px;
}

#showall{
margin-right: 20px;
}

#showall:hover, #hideall:hover{
background: #707070;
color: #fff;
}

.response{
display: none;
}

ul.faq, ul.faq li{
list-style: none !important;
}

.faq h3{
background: #fff;
padding: 10px 10px;
border: 1px solid #e5e5e5;
}

.faq h3:hover, .faq h3.titleopen{
background: #808080;
color: #fff;
}

.faq h3:after{
content: '+';
float: right
}

.faq h3.titleopen:after{
content: '-'
}

.faq_qtn{
cursor: pointer;
-webkit-transition: color .2s ease, background .2s ease;
-moz-transition: color .2s ease, background .2s ease;
-o-transition: color .2s ease, background .2s ease;
transition: color .2s ease, background .2s ease;
}

.para {
padding-top: 20px;
padding-right: 30px;
font-size: 18px;
text-align: justify;
line-height: 30px;
padding-left: 30px;
}
</style>

HTML:

<div class="faq_container">
<div id="show_hide_wrap">
<div id="showall" class="faq_qtn">SHOW ALL</div>
<div id="hideall" class="faq_qtn">HIDE ALL</div>
</div>
<ul class="faq">
<!-- This is the first Q&A -->
<li>
<h3 class="faq_qtn">This is a first question of FAQ Module</h3>
<div class="response">
<p class="para">Here is the answer to the first question.</p>
</div>
</li>
<!-- This is the second Q&A -->
<li>
<h3 class="faq_qtn">Here goes your second question of FAQ Module</h3>
<div class="response">
<p class="para">Here is the answer to the second question.</p>
</div>
</li>
<!-- This is the third Q&A -->
<li>
<h3 class="faq_qtn">Here is a third question of FAQ Module and you can add as many as questions</h3>
<div class="response">
<p class="para">Here is the answer to the third question.</p>
</div>
</li>
<!-- Add additional questions -->
</ul>
</div>

Customization:

No need to customize it. Just copy-paste. Rest edit the code as per comments and need.

Recommended For You:
How To Copy Text From A Div And Paste It Into A TextArea Using JavaScript?

Troubleshooting the Errors:

Do it with concentration and patience. Check your all steps and again and all codes or scripts. If you find any error you can contact us anytime via comment or better via email, We are always here to help you.

Final Words:

That’s all we have. We hope that you liked this article. If you have any problem with this code in your template then feel free to contact us with a full explanation of your problem. We will reply to you as time allows us If you have any doubts or problems please comment below. We are happy to help you! If you liked this article, Don’t forget to share this with your friends so they can also take benefit from it and leave.

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *