I am having trouble with making accordion buttons. My JS code is not working | Sololearn: Learn to code for FREE!

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

9/21/2020 4:12:30 PM

Matthew

2 Answers

New Answer

0

I tried that and it still didn't work