Created
September 1, 2020 07:31
-
-
Save CSElliyas/4eae7dfb19743a00348f621a1ec1117c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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