Liquid, JavaScript, themes, sales channels
Hey Guys,
I am trying to implement a customized progress bar to one of my shopify pages and I need Javascript to implement it. Unfortunately my script is not working for shopify (even though it works on a different website)
I broke it down in the easiest way, only containing the not functioning parts:
HTML:
...
<div id="output"></div>
...
JS
var bodyy = document.querySelector("body");
document.addEventListener("scroll", () => {
output.textContent = bodyy.scrollTop;});
What's supposed to happen is that the output div changes depending on the scrolling position. But it returns 0 no matter what (the page is long enough to scroll and overflow is set to scroll)
Is anyone able to figure out why it doesn't recognize the scrolling position?
Thank you in advance!
I think it should help.
document.addEventListener("scroll", () => {
output.textContent = document.documentElement.scrollTop;});
User | RANK |
---|---|
38 | |
29 | |
13 | |
11 | |
8 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023