Skip to content

Instantly share code, notes, and snippets.

@nickberens360
Last active April 10, 2017 15:12
Show Gist options
  • Save nickberens360/6719590 to your computer and use it in GitHub Desktop.
Save nickberens360/6719590 to your computer and use it in GitHub Desktop.
Simple jQuery FAQ / Accordion code
jQuery( document ).ready(function( $ ) {
var question = $('.nAccordian .question');
var answer = $('.nAccordian .answer');
$(question).click(function(){
$(answer).slideUp();
$(this).next().slideToggle('fast');
});
});
/*HTML*/
<div class="nAccordian">
<div class="question">
Question?
</div>
<div class="answer">
Answer.
</div>
<div class="question">
Question?
</div>
<div class="answer">
Answer.
</div>
<div class="question">
Question?
</div>
<div class="answer">
Answer.
</div>
<div class="question">
Question?
</div>
<div class="answer">
Answer.
</div>
</div>
/*CSS*/
.answer{
display:none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment