Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hey,
Lately I've been having problems with my scroll to top button not stopping at a specific section.
I've added the button through a section app which works just fine, but I cant seem to figure out how to make it land in the proper area. It keeps going straight back to the top.
I've done some edits in the actual section folder of this button and this is the current code that I'm using:
<script> (function () { window.addEventListener('DOMContentLoaded', () => { const scrollBtn01 = document.querySelector('.btn-scroll-01'); const targetSection = document.querySelector('#shopify-section-15d62b59-d08d-4ba2-823b-06fe5c10472f'); const btnVisibility = () => { if (window.scrollY > 400) { scrollBtn01.classList.add('scroll-01--show'); } else { scrollBtn01.classList.remove('scroll-01--show'); } }; document.addEventListener('scroll', () => { btnVisibility(); }); scrollBtn01.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth', }); }); }); })(); </script>
If anyone can help me finally solve this, i'd greatly appreciate it. Thanks!
URL : jasaoslaj.com
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025