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?
codepen.io/Bonauze/pen/vGRXJZ
July 12th 19 at 17:16
2 answers
July 12th 19 at 17:18
Solution
if(contentItem.hasClass('active')){
contentItem.removeClass('active');
 } else {
contentItem
.eq(itemPos)
.add(item)
.addClass('active')
.siblings()
 .removeClass('active'); 
 };
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