Hi there,
I have 3 tabs on a page, and I want to add buttons to the bottom to direct person to next tab
i.e. to open tab and scroll to top.
I found a few post about this, but its not quite working.
https://theme.co/apex/forum/t/link-to-tab-in-the-same-page/18331
https://theme.co/apex/forum/t/link-that-opens-a-tab-within-same-page/4668
It looks like the Tab element in a recent pro update has changed ID to legacy.
Can you help.
Code I have in javascript is:
jQuery( function($){
$( window ).on('load resize', function(){
scroll_to_tab ( location.href.split("#tab-").slice(-1)[0] );
});
$( '.link_to_tab' ).on('click touchstart', function(){
var mylink = $(this).attr("href");
scroll_to_tab ( mylink.split("#tab-").slice(-1)[0] );
});
function scroll_to_tab ( tab_id ) {
console.log(tab_id);
var tab_nav = $('.x-nav-tabs .x-nav-tabs-item a[data-cs-tab-toggle="' + tab_id + '"]');
if(tab_nav.length >=1) {
$( tab_nav ).trigger('click');
$('html,body').stop().animate({scrollTop: $(tab_nav).offset().top - ( $('.x-navbar').height() + 50 ) },700 ,'swing');
}
}
});
Will post page this is on, in private reply.
Many thanks
