Created
February 15, 2013 10:49
-
-
Save kezabelle/4959657 to your computer and use it in GitHub Desktop.
Quick and dirty nested accordian in jQuery, a reminder for myself.
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
/* | |
* Taken from http://sower.com.au/2011/06/jquery-multilevel-accordion-in-10-lines-of-code/ | |
*/ | |
$(document).ready(function() { | |
$('.menu li ul').hide(); | |
$('.menu li a').click( | |
function(evt) { | |
evt.preventDefault(); | |
evt.stopPropagation(); | |
var openMe = $(this).next(); | |
var mySiblings = $(this).parent().siblings().find('ul'); | |
if (openMe.is(':visible')) { | |
openMe.slideUp(); | |
} else { | |
mySiblings.slideUp(); | |
openMe.slideDown(); | |
} | |
} | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment