this is probably something stupid, but I can't find what I'm doing wrong. I've been trying to make a DOM element appear when the body is scrolled to a certain height. So I've set an eventlistener on the window to check for scrolling and I check the scrollTop of the body to get the scrollposition.
This is working perfectly in Chrome, but in Firefox the scrollTop always stays 0, no matter what I try. I've also tried checking the scrollTop of other elements, but that does not register either. I can't find any documentation on scrollTop that explains how this works across different browsers. Does anyone know why this is not working in Firefox? Or am I just doing this in a silly way?
(function () {
var element = document.getElementById("body");
window.addEventListener('scroll', function (e){
var scrollPos = element.scrollTop;
console.log(scrollPos);
});
})()
Ofcourse this is part of a larger script, but I've narrowed it down and created a new snippet to make sure that this code is creating the problem.