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; } })

21st Sep 2020, 4:12 PM
Matthew
2 Réponses
0
I tried that and it still didn't work
22nd Sep 2020, 8:18 PM
Matthew