Skip to content

Instantly share code, notes, and snippets.

@agragregra
Last active November 13, 2023 16:48
Show Gist options
  • Save agragregra/4f5ece39d2d3909cc671 to your computer and use it in GitHub Desktop.
Save agragregra/4f5ece39d2d3909cc671 to your computer and use it in GitHub Desktop.
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