0
I am having trouble with making accordion buttons. My JS code is not working
document.querySelectorAll ('.accordion__button').foreach(button=>{ button.addEventListner('click', ()=>{ const accordionContent = button.nextEventSibling }) button.classList.toggle( 'accordion__button--active'); if (button.classList.contains ('accordion__button--active')) { accordionContent.style.maxHeight = accordionContent.scrollHeight + 'px'; } else { accordionContent.style.maxHeight = 0; } })
2 Answers
0
I tried that and it still didn't work