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. ?
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.