Hi
Your script seems to access dom elements directly and it is not a supported way of hiding/showing fields or tabs.
Please use the Dynamics 365 client-side libraries to show/hide fields or tabs.
Since you are using Dynamics 365 Online, I would recommend you use formcontext.getControl to get hold of the attribute and then use setVisible function to hide or show. Please see below
Please visit the links below to know more about out of the box client-side libraries
docs.microsoft.com/.../clientapi-form-context
You can get get the formcontext using the following line
var formContext = executionContext.getFormContext(); // get formContext
Please refer to the link below to know more about passing execution context
carldesouza.com/.../
Once you got the formcontext, you can show / hide fields, tabs or sections as shown below
To show/hide a field : formContext.getControl("fieldname").setVisible(true / false); // true or false to hide or show
To show/hide a tab : formContext.ui.tabs.get(tabName).setVisible(true/false)
To show/hide a section : formContext.ui.tabs.get(tabName).sections.get(sectionName).setVisible(true/false);
To hide/show a field in a particular section in a tab : formContext.ui.tabs.get(tabName).sections.get(sectionName).controls.get("fieldname").setVisible(true/false)
Please note that you do not need any additional javascript libraries to do this.
Some useful links
docs.microsoft.com/.../formcontext-ui-tabs
docs.microsoft.com/.../controls
Hope this helps