Created
August 18, 2017 20:31
-
-
Save mpukit/8a895824146d62f7ec5ea088e2aea492 to your computer and use it in GitHub Desktop.
Basic Content/Menu Accordion
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
/* ===================================== | |
Accordion | |
======================================== */ | |
var accItem = document.getElementsByClassName('accordionItem'); | |
var accHD = document.getElementsByClassName('accordionItemHeading'); | |
for (i = 0; i < accHD.length; i++) { | |
accHD[i].addEventListener('click', toggleItem, false); | |
} | |
function toggleItem() { | |
var itemClass = this.parentNode.className; | |
for (i = 0; i < accItem.length; i++) { | |
accItem[i].className = 'accordionItem close'; | |
} | |
if (itemClass == 'accordionItem close') { | |
this.parentNode.className = 'accordionItem open'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment