Skip to content

Instantly share code, notes, and snippets.

@magnificode
Created February 6, 2013 18:17
Show Gist options
  • Select an option

  • Save magnificode/4724584 to your computer and use it in GitHub Desktop.

Select an option

Save magnificode/4724584 to your computer and use it in GitHub Desktop.
Super Simple jQuery Accordion
(function($) {
var allPanels = $('.accordion > div.acc-content').hide();
$('.accordion > div.acc-more > a').click(function() {
$this = $(this);
$target = $this.parent().next();
if(!$target.hasClass('active')){
allPanels.removeClass('active').slideUp();
$target.addClass('active').slideDown();
}
$this.slideUp();
return false;
});
$('.accordion > .acc-content > div.acc-less').click(function() {
if( $(this).parent().hasClass('active')){
$(this).parent().slideUp();
$(this).parent().removeClass('active');
$('.acc-more > a').slideDown();
}
return false;
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment