Thursday, 12 September 2013

faq toggle adding selector

faq toggle adding selector

I have toggle faq.
When I click on " + " it toogle answer and show/hide it.
I want to make toggle if I click on " + " and also on title of question.
Question:
How to toggle answer with h3 element (title of question) and/or *+* button?
HTML:
<div class="box boxFaq clearfix">
<div class="boxTitle">
<h3>Question</h3>
</div>
<button class="clearfix">+</button>
<div style="clear: both;"></div>
<div class="boxContent clearfix toggle">
Answer answer answer
</div>
</div>
JS:
jQuery(document).ready(function() {
jQuery('button').click(function() {
jQuery(this).next().next('.toggle').slideToggle();
if (jQuery(this).text() === '+') {
jQuery(this).html('-');
}
else {
jQuery(this).html('+');
}
});
});

No comments:

Post a Comment