-
AuthorPosts
-
August 29, 2024 at 5:38 pm #1465689
Hello,
I have several links pointing to individual tabs of the tab section, but the page doesn’t scroll to the position of the tab section.
Thanks for your help!August 30, 2024 at 11:27 am #1465755Hey Leeonella,
Thank you for the inquiry.
We may need to inspect the site in order to properly check the issue. Please provide the login details in the private field. In the meantime, you can try this script in the functions.php file:
// script to scroll to the active tab section function ava_custom_script_tab_section_scroll() { ?> <script type="text/javascript"> (function($) { function avTriggerScrollToTab(selector, event) { $(selector).on(event, function() { var isLoadEvent = event === 'load'; var locationHash = isLoadEvent ? window.location.hash : $(this).attr('href'); var hash = isLoadEvent ? locationHash : locationHash.substring(locationHash.indexOf('#')); var tab = $('.av-section-tab-title[href="' + hash + '"]'); var parentContainer = tab.closest('.av-tab-section-outer-container'); if (tab.length && parentContainer.length) { var position = parentContainer.offset().top; tab.trigger('click'); if (hash) { setTimeout(function() { $('html, body').animate({ scrollTop: position - 100 }, 500); }, 300); } } }); } $(document).ready(function() { var tabs = $('.av-tab-section-container'); if (tabs.length === 0) return; avTriggerScrollToTab('.menu-item a', 'click'); avTriggerScrollToTab(window, 'load'); }); })(jQuery); </script> <?php } add_action('wp_footer', 'ava_custom_script_tab_section_scroll', 9999);
Best regards,
IsmaelAugust 30, 2024 at 2:19 pm #1465799Hi Ismael,
thank you very much, it’s working now!
I only had to adapt the line of code
avTriggerScrollToTab('.menu-item a', 'click');
with the corresponding CSS classAugust 30, 2024 at 4:18 pm #1465809Hi,
Great, I’m glad that Ismael could help you out. Please let us know if you should need any further help on the topic, or if we can close it.
Best regards,
RikardAugust 30, 2024 at 5:57 pm #1465821Thank you, please close it.
August 31, 2024 at 12:42 pm #1465872Hi,
Thanks for letting us know. Please open a new thread if you should have any further questions or problems.
Best regards,
Rikard -
AuthorPosts
- The topic ‘Linking to tab section not working’ is closed to new replies.