Skip to content

Instantly share code, notes, and snippets.

@CSElliyas
Created September 1, 2020 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CSElliyas/4eae7dfb19743a00348f621a1ec1117c to your computer and use it in GitHub Desktop.
Save CSElliyas/4eae7dfb19743a00348f621a1ec1117c to your computer and use it in GitHub Desktop.
//accordin js
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment