Skip to content

Instantly share code, notes, and snippets.

@nikartx
Created July 24, 2015 17:35
Show Gist options
  • Save nikartx/730a868bcbe82a155be0 to your computer and use it in GitHub Desktop.
Save nikartx/730a868bcbe82a155be0 to your computer and use it in GitHub Desktop.
jQuery Accordeon
JS:
$(".accordeon dd").hide().prev().click(function() {
$(this).parents(".accordeon").find("dd").not(this).slideUp().prev().removeClass("active");
$(this).next().not(":visible").slideDown().prev().addClass("active");
});
CSS:
.accordeon .active { color: red }
HTML:
<div class="accordeon">
<dl>
<dt>Заголовок</dt>
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam ea, accusamus. Numquam non commodi ipsum debitis repudiandae amet vero itaque, deserunt, ad neque libero quae officia. Facilis non, possimus doloribus! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid quis voluptatem repellat? Blanditiis iste, exercitationem porro, magni amet cupiditate enim, labore tenetur, praesentium quam consequuntur nesciunt. Culpa dicta adipisci voluptatem.</dd>
</dl>
<dl>
<dt>Заголовок</dt>
<dd>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid quis voluptatem repellat? Blanditiis iste, exercitationem porro, magni amet cupiditate enim, labore tenetur, praesentium quam consequuntur nesciunt. Culpa dicta adipisci voluptatem.</dd>
</dl>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment