Accordion animation

Hi everyone

I have a little problem, I’m trying to figure out how to close the accordion elements if I click again.
at the moment it closes an accordion element if it is expanded by clicking on it.

But my question is how do I close again the element that is displayed. ?

thank you very much in advance for your help.
you can see here my code: https://codepen.io/Alanes/pen/ExXqXVY

Currently you are using the “closed” class to keep the element closed and then removing that class to open it. My suggestion would be to do the opposite: By default the elements are closed and no class is needed, then add the “open” class to the element when it should be opened (and remove it when it should be closed again).

I think this is going to make your logic much easier.

Thank you @bbsmooth !

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.