MerMory-Alloc• 250
@MerMory-Alloc
Posted
Great work here, I liked how you did some magic to it with animation. about you question you can add this code inside the event function.
for(j=0; j < btnAccordion.length; j++){
if(btnAccordion[j].innerHTML != this.innerHTML){
btnAccordion[j].classList.remove("active");
btnAccordion[j].nextElementSibling.style.display= "none";
btnAccordion[j].firstElementChild.style.transform = 'rotate(0deg)';
}
}
it basically will iterate through all the answers(btnAccordion elements) then checks if it is the element that just got clicked or not . if it is not, it will remove the class active from it and hide it. Hope this helps .
0