I don't Understand what you are trying to do.
If you collapse the Tab all fields are hidden,and when you expand It all fields are shown.
With this code
Xrm.Page.ui.controls.get("fieldname").setVisible(true/false);
You can show /hide any field.
If you want to show/hide a Tab use this
Xrm.Page.ui.tabs.get("TabName").sections.get("SectionName").setVisible(false);
Hope this Helps