Created
November 17, 2012 23:17
-
-
Save ataylorme/4101294 to your computer and use it in GitHub Desktop.
Simple jQuery accordion
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
var headings = $('h3'), | |
paras = $('p'); | |
paras.hide().eq(0).show(); | |
headings.click(function() { | |
var cur = $(this); //save the element that has been clicked for easy referal | |
cur.siblings('p').slideUp(); //hide all the paragraphs | |
cur.next('p').slideDown(); //get the next paragraph after the clicked header and show it | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A very simple jQuery accordion. I recommend using more specific targets than h3 and paragraph tags. Fiddle is here