get how much i scroll in js

Solutions on MaxInterview for get how much i scroll in js by the best coders in the world

showing results for - "get how much i scroll in js"
Nico
11 Oct 2016
1//To detect how much the user has scrolled the page vertically in terms of pixels
2//from the very top, in JavaScript, we would probe either window.pageYOffset, 
3//or in older versions of IE, one of several variants of document.body.scrollTop, 
4//whichever property is supported:
5var scrollTop = window.pageYOffset || (document.documentElement || document.body.parentNode || document.body).scrollTop
6
7//Using jQuery instead, the equivalent would be:
8var scrollTop = $(window).scrollTop() //Best