Join the Voxel Guide Community!

Get Involved

Voxel Theme Version: 1.5.4 | Elementor Plugin Version: 3.28.0

You are now eligible to list your profile publicly!

Hide empty elementor Tabs

Description/Instructions

We know after VX  Template Tabs Widget deprecated we will use elementor tabs. Sometimes, places don’t have the content like others so may be some tabs has no content. this code will hide these empty tabs.

Instructions

On the page you want this to appear, add an HTML widget (FREE) and paste the code in there. Be sure to have before your code and after the code if it isn't already inserted above.

document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
// Find all tab content elements
const tabContents = document.querySelectorAll('.e-n-tabs-content > div[id^="e-n-tab-content-"]');

tabContents.forEach(function(tabContent) {
// A tab is considered empty only if it has no children at all
// OR if it only has empty container elements
let isEmpty = true;

// If the tab has any HTML content at all (not just whitespace)
if (tabContent.innerHTML.trim() !== '') {
// Check for any actual content
// This will detect images, videos, text, buttons, etc.
const allElements = tabContent.querySelectorAll('*');

for (let i = 0; i < allElements.length; i++) {
const element = allElements[i];

// Check if this is a container element
const isContainer = element.tagName === 'DIV' ||
element.tagName === 'SECTION' ||
element.classList.contains('e-con') ||
element.classList.contains('e-con-inner');

// If it's not just a container, the tab has content
if (!isContainer || element.innerHTML.trim() !== '') {
isEmpty = false;
break;
}
}
}

// If the tab is truly empty, hide it
if (isEmpty) {
// Get the tab ID
const tabId = tabContent.getAttribute('id');

// Find the corresponding tab title
const tabTitle = document.querySelector(`button[aria-controls="${tabId}"]`);

if (tabTitle) {
// Hide the tab title
tabTitle.style.display = 'none';
}
}
});
}, 800);
});

  • JS
Copy Code

Let's Chat About this Snippet

Chat Toggle
Voxel Guide AI
Voxel Guide AI
Voxel Guide AI
Voxel Guide AI
Ask me anything about Voxel!
Send
Powered by AI24