Selecting a specific Elementor tab with a link.
A quick customer request solved with Javascript.
For those who use the Elementor builder, you will already be familiar with the tabs element.
A minus of this element is that there are no links in the tabs, this means that you cannot directly load a specific tab when the page is opened and the default is necessarily loaded.
The problem is solved by choosing one of the two scripts I wrote (I prefer the second one which gives you a link per tab).
Solution 1: You use the following script to open a specific tab during loading:
window.onload = function() {
document.getElementById("ΓΡΑΨΤΕ_ΤΟ_ID_ΤΗΣ_ΚΑΡΤΕΛΑΣ").click();
};
Solution 2nd: The following script creates links per tab in order
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
jQuery(function($){
let desktoptitles = $('.elementor-tab-desktop-title');
let mobiletitles = $('.elementor-tab-mobile-title');
let strings = ['?KARTELA1',
'?KARTELA2',
'?KARTELA3',
'?KARTELA4',
'?KARTELA5'
];
strings.forEach( (string,i) => {
if (window.location.href.indexOf(string) > -1) {
desktoptitles.eq(i).click();
mobiletitles.eq(i).click();
$('html, body').animate({
scrollTop: desktoptitles.eq(i).offset().top - 100
},'slow');
} } );
}); }, 1200); });
Immediately after that just call the page link and add: ?KARTELA1 etc
This post is also available in: Ελληνικά