Skip to content
Advertisement

Close all collapsible content at once

I have the following code:

JavaScript
JavaScript
JavaScript

There are two collapsible buttons called First question and Second question. You click on one of them to show the content and you click again to hide the content.

If you opened multiple collapsible contents you have to click on each of them to close all. I need a button that allows to close all at once.

But I don’t know how to tell the javascript code not to close only one but every content.

Do you know how I can do that?

Advertisement

Answer

I would delegate

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement