Last active
April 10, 2017 15:12
-
-
Save nickberens360/6719590 to your computer and use it in GitHub Desktop.
Simple jQuery FAQ / Accordion code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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