Hello! I am working on a page that has a tab element in one of the sections. I have 3 feature boxes right above the tabs that each have a link in the text that should link to its corresponding tab below. I can see the url is adding the “#tab-x” attribute, but the tabs are not opening. I have tried lots of solutions form the forums with custom javascript. The page url is sarascottdesigner.com/business.
Can someone please help me to get this to work?
Thanks!
Sara
This is my current javascript:
(function($){
var tabnav = location.href.split("#tab-").slice(-1)[0];
if ( tabnav || tabnav != '' ) {
$( document ).ready ( function() {
console.log(tabnav);
var navbar = $('.x-navbar').outerHeight();
$('.x-nav-tabs .x-nav-tabs-item').removeClass('active');
$('.x-nav-tabs .x-nav-tabs-item [data-cs-tab-toggle="' + tabnav + '"]').parent('.x-nav-tabs-item').addClass('active');
$('.x-tab-content .x-tab-pane').removeClass('active');
$('.x-tab-content [data-cs-tab-index="' + tabnav + '"]').addClass('active');
setTimeout ( function() { //Let's trigger the scroll animation just after the content is displayed.
var yloc = $('.x-tab-content [data-cs-tab-index="' + tabnav + '"]').offset().top;
console.log($('.x-tab-content [data-cs-tab-index="' + tabnav + '"]').offset().top);
console.log('tab: ' + tabnav + ', yloc: ' + yloc);
$('html, body').animate({
scrollTop: yloc
}, 850, 'easeInOutExpo');
}, 750 );
} );
}
})(jQuery);