Is there a way to have a Tab Section (with ID name/direct URL) open to the tab and also scroll down on the page to where that section is? Right now it’s just opening, but it’s not scrolling down.
Hey amyncuih,
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:
add_action( 'wp_footer', 'ava_custom_script_tab_section' );
function ava_custom_script_tab_section() {
?>
(function($) {
function scrollToTab(s, e) {
$(s).on(e, function(event) {
var anchor, loc, cur, hash, tab, parent, pos;
if( e == 'load' ) {
loc = window.location.hash;
hash = loc;
} else {
loc = $(this).attr('href');
hash = loc.substring(loc.indexOf('#'));
}
tab = $('.av-section-tab-title[href="'+ hash +'"]');
parent = tab.parents('.av-tab-section-outer-container');
pos = parent.offset();
tab.trigger('click');
if(hash) {
setTimeout( function() {
$(window).scrollTop( pos.top - 100 )
}, 100 );
}
});
}
scrollToTab( '.avia-buttonrow-wrap a', 'click' );
scrollToTab( window, 'load' );
})(jQuery);
<?php
}
Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
Best regards,
Mike
Adding that code is giving errors in the footer and it didn’t work.