Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1479351

    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.

    #1479486

    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

    #1479646

    Adding that code is giving errors in the footer and it didn’t work.

    #1479659

    Hi,
    Perhaps you copied the code from an email instead of the forum, or you have an error in your child theme functions.php file.
    Please include a admin login in the Private Content area so we can examine.

    Best regards,
    Mike

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.