Skip to content

Instantly share code, notes, and snippets.

@kezabelle
Created February 15, 2013 10:49
Show Gist options
  • Save kezabelle/4959657 to your computer and use it in GitHub Desktop.
Save kezabelle/4959657 to your computer and use it in GitHub Desktop.
Quick and dirty nested accordian in jQuery, a reminder for myself.
/*
* 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