(function($) { const tabMap = { 'one': '#e-n-tab-title-1192959592', // Spa Packages for One 'two': '#e-n-tab-title-1192959591' // Spa Packages for Two }; function openTabFromHash(retryCount = 0) { const hash = window.location.hash.replace('#', ''); if (!hash || !tabMap[hash]) return; const $tabButton = $(tabMap[hash]); if ($tabButton.length === 0) { if (retryCount < 10) { setTimeout(() => openTabFromHash(retryCount + 1), 300); } return; } console.log('Activating tab for hash:', hash); $tabButton.trigger('click'); // Scroll to tab container for better UX const $container = $tabButton.closest('.e-n-tabs'); if ($container.length) { $('html, body').animate({ scrollTop: $container.offset().top - 100 }, 600); } } $(window).on('elementor/frontend/init', function() { setTimeout(() => openTabFromHash(), 500); }); $(window).on('hashchange', function() { openTabFromHash(); }); })(jQuery);