Created
April 11, 2022 10:24
-
-
Save wpflames/a0f4197060a31e4500f1779ae98af7c2 to your computer and use it in GitHub Desktop.
Accordion with Vanilla JS
This file contains hidden or 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
| const accTitle = document.getElementsByClassName("accordion-title"); | |
| let i; | |
| for (i = 0; i < accTitle.length; i++) { | |
| accTitle[i].addEventListener("click", function() { | |
| this.classList.toggle("active"); | |
| let panel = this.nextElementSibling; | |
| panel.classList.toggle("active"); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment