Custom CSS ID link to Elementor Nested Tabs

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 the HTML widget and place it right before your tabs widget.
Then, add your CSS ID to your tabs.

Your final URL to arrive on a tab will be https://yourwebsite.com/?tab=cssid

				
					<script>window.onload = function() {
    const urlParams = new URLSearchParams(window.location.search);
    const openTabId = urlParams.get('tab'); // 'tab' is the parameter in the URL

    if (openTabId) {
        const targetTabButton = document.getElementById(openTabId);
        if (targetTabButton && targetTabButton.classList.contains('e-n-tab-title')) {
            targetTabButton.click(); // Simulates a tab button click
        }
    }
};

</script>
				
			
Want to leave a comment ?

2 Responses

  1. Hello. The code works very well. I also added like a placeholder to scroll to the tab, with the function: .scrollIntoView(), right after the .click() function. Everything works excellent. Thank you.

  2. Didn’t work for me. Probably in
    Doing it wrong. When clicking in a link (button) the pages refresh’s and doesn’t go smoothly to the tab. Can you send me a code where this o cuts smoothly and not refreshing the page? Thanks ????

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to see more code snippets?

Additional Emails per Products for WooCommerce

Adds a custom tab in WooCommerce products to write an email specific to each product. This will be sent in a dedicated email.

Create a custom gallery with Elementor

With this code we gonna add a custom gallery to an elementor page

Display the total weight in the cart and order page of woocommerce

This code will allow you to know the weight of the order in the cart and order pages of woocommerce.

Custom CSS ID link to Elementor Nested Tabs

This script will allow us to run an URL directly to an Elementor tab

Create a dropdown from a Custom Post Type list

This code will allow us to display a drop-down menu which lists all the CPTs present in our ACF

Filter number of orders by country

Set up a submenu that allows us to filter a date range and display the number of orders depending on the country.
Let's talk ?

A question about WordPress?
A web project to be outsourced to a freelancer?
I am your man!