I am trying to get the top offset of a div, and I have the following code that gets run when the page gets scrolled:
var $elem = document.querySelector(selector);
var elemTop = $elem.offsetTop;
console.log(elemTop);
But when I scroll it always prints 0
to the console, even though the element is below the fold.