On Google, chrome document.body.scrollTop always returns 0.
I'm trying to
if (window.pageYOffset > 0) { st = window.pageYOffset; } else if (document.documentElement.scrollTop > 0) { st = document.documentElement.scrollTop; } else { st = document.body.scrollTop; }
But does not work. document.body.scrollTop works in firefox.
Even in the chrome console, when I have this code in the console, it does not work.
enter code here $('html, body').stop().animate({ scrollTop: 50 }, 500);
source share