jQuery(document).ready(function() { jQuery('.tabs .tabLinks a').on('click', switchTab); var observer = new window.MutationObserver(function(mutations, observer) { jQuery('.tabs .tabLinks a').on('click', switchTab); }); jQuery('.tabLinks').each( function () { observer.observe(this, { childList: true, subtree: true }); }); }); function switchTab(e) { var currentAttrValue = jQuery(this).attr('href'); // Show/Hide Tabs jQuery('.tabs ' + currentAttrValue).show().siblings().hide(); // Change/remove current tab to active jQuery(this).parent('li').addClass('active').siblings().removeClass('active'); e.preventDefault(); }