Proposal: Cleaning DOM under used Tab (Content via AJAX)

Proposal: Cleaning DOM under used Tab (Content via AJAX)

I know subject line does not do justice in explaining the problem, so here it is:
I have a pane in which content is displayed when any of the four (or n) tabs is selected. The content is loaded via AJAX hook. There are some DOM components which are shared between all the four tabs.
When I load content under Tab 4 after view Tab 1 (or any tab other than 4th), some DOM components repeat (as they where already there under Tab 1). This repetition causes multiple DOM elements with same IDs and therefore leaving some functionality dysfunctional.
I suggest, as soon as we shift to different tab, content under last viewed tab should be erased, therefore maintaining uniqueness of IDs.
What does the community feel about this case?
I am willing to work on it, if you feel this is the right solution for this problem. It will be nice to hear about other possible approaches too.
<br clear="all">Best Wishes,
Varun Gupta