Tabs by jQuery. How to make folding?

Tell me the solution...
How to implement the decommissioning of the unit, if second time clicked on button?
July 12th 19 at 17:16
2 answers
July 12th 19 at 17:18
 } else {
July 12th 19 at 17:20
As you fold the other tabs when you click other buttons
Don't understand what the difficulty is to repeat a piece of written script, only in a different action?

Check whether the button .active (or what have you), if there is, close the tab and clean .active

Find more questions by tags JavaScriptHTMLCSSjQuery