All things Shopify and commerce
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi,
How can i make the button 'Shop Now' on the mega nav image open in a new tab? www.kiki-health.com?
Hello @gina16
Please replace this HTML code:
<a href="/collections/vitamins-minerals-omegas" class="btn btn--overlay btn--x-small btn--secondary">
<span>Discover</span>
</a>
with This:
<a href="/collections/vitamins-minerals-omegas" target="_blank" class="btn btn--overlay btn--x-small btn--secondary">
<span>Shop Now</span>
</a>
Result:
my reply helpful? Click Like to let me know!
your question answered? Mark it as an Accepted Solution.
Hi and thank you soo much for coming back to me.
Where can I find this code to replace?
Hi @gina16,
You can add this script just before the closing </body> tag.
<script>
var discoverButton = document.querySelector('a.btn span');
// Check if the text inside the span is 'Discover'
if (discoverButton && discoverButton.textContent.trim() === 'Discover') {
// Get the parent anchor element and add target="_blank"
discoverButton.closest('a').setAttribute('target', '_blank');
}
</script>
The above code will add the attribute to that button.
Best,
Thanks Rohail, but what file do I add it to?
Hi @gina16,
You can add this to theme.liquide file.
Best,