Elementor

Custom CSS ID link to Elementor Nested Tabs

Josselyn Jayant
28 October 2025
Lecture : 1 min
Updated 6 November 2026

If you want to create URLs to take your visitors to a particular tab with Elementor’s nested tabs, as of this writing it doesn’t work (April 23, 2024).

Here’s how to make it work.

Paste this code in Elementor in the Custom Code options.
Then, add your CSS ID to your tabs.

Your final URL to arrive on a tab will be https://yourwebsite.com/page#tab

				
					<script>
// Solution simplifiée utilisant les IDs natifs d'Elementor
(function($) {
    'use strict';
    
    $(window).on('elementor/frontend/init', function() {
        
        // Fonction pour activer un onglet par son ID
        function activateTabById(tabId) {
            const $targetTab = $('.e-n-tab-title#' + tabId);
            
            if ($targetTab.length) {
                // Vérifier si l'onglet n'est pas déjà actif
                if (!$targetTab.attr('aria-selected') || $targetTab.attr('aria-selected') === 'false') {
                    $targetTab.trigger('click');
                }
                
                // Scroll vers l'onglet
                setTimeout(function() {
                    const $container = $targetTab.closest('.elementor-widget-n-tabs');
                    if ($container.length) {
                        $('html, body').animate({
                            scrollTop: $container.offset().top - 100
                        }, 300);
                    }
                }, 200);
                
                return true;
            }
            return false;
        }
        
        // Activer un onglet depuis l'URL au chargement
        function activateFromHash() {
            const hash = window.location.hash;
            if (hash) {
                const tabId = hash.substring(1);
                activateTabById(tabId);
            }
        }
        
        // Mettre à jour l'URL quand on clique sur un onglet
        function initTabClicks() {
            $('.e-n-tab-title').off('click.taburl').on('click.taburl', function() {
                const tabId = $(this).attr('id');
                if (tabId && !tabId.startsWith('e-n-tab-title-')) {
                    // Ne mettre à jour l'URL que si l'ID est personnalisé (pas auto-généré)
                    history.pushState(null, null, '#' + tabId);
                } else if (tabId) {
                    // Pour les IDs auto-générés, on peut aussi les utiliser
                    history.pushState(null, null, '#' + tabId);
                }
            });
        }
        
        // Initialiser
        setTimeout(function() {
            initTabClicks();
            activateFromHash();
        }, 500);
        
        // Gérer les changements d'URL (bouton retour du navigateur)
        $(window).on('hashchange', activateFromHash);
        
        // Réinitialiser quand Elementor recharge des widgets
        elementorFrontend.hooks.addAction('frontend/element_ready/n-tabs.default', function($scope) {
            setTimeout(function() {
                initTabClicks();
            }, 100);
        });
    });
    
    // Fallback si elementor/frontend/init ne se déclenche pas
    $(document).ready(function() {
        setTimeout(function() {
            if ($('.e-n-tab-title').length > 0) {
                $(window).trigger('elementor/frontend/init');
            }
        }, 1500);
    });
    
})(jQuery);
	</script>
				
			

Compatibility and limits

  • Works with Elementor’s Nested Tabs widget (tab titles with the e-n-tab-title class).
  • Paste it in Elementor > Custom Code (Elementor Pro), or in your site footer with a snippets plugin.
  • Give each tab a CSS ID in its advanced settings; links then look like /page/#my-tab. The browser back button reopens the previous tab.
Before you start

Back up your site before changing any code, and test on a staging copy first.

Need help adding it?

I can take care of it, or adapt it to your store.

Read also

Elementor · WooCommerce

Stock Status Widget for Elementor

Elementor · Plugins

Back to Top for Elementor

Elementor · Plugins · WooCommerce

WooCommerce Gallery Hover for Elementor Loop