Anchor link to a custom tab
-
Hi,
I am trying to add a anchor link to a custom tab(DOA Policy) in the single product page.
My website page: https://website.saltiesreefies.com/tactical-aquatics/product/amazon-sword/#tab-doa-policy
I installed
* Custom Product Tabs for WooCommerce
* Custom CSS & JS pluginSearching the support topics added below code to the Js:
document.addEventListener('click', function (event) { if (event.target.hash && event.target.hash.includes('tab-')) { // Ignore other click events event.preventDefault(); // Set up variables const tabName = event.target.hash.replace('#tab-', ''); const tabLink = document.getElementById('tab-title-' + tabName) const tab = document.getElementById('tab-' + tabName); // Click on tab title to display tab tabLink.getElementsByTagName('a')[0].click(); // Scroll to tab jQuery('html, body').animate({ scrollTop: tab.parentElement.offsetTop }, 300); } })
Clicking the anchor linked text “Please see our DOA policy before placing an order.” under Add to curt button opens the tab, but doesn’t jump or scroll to that section. Instead it goes to the top of the page.
Please help
The page I need help with: [log in to see the link]
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘Anchor link to a custom tab’ is closed to new replies.