📌  相关文章
📜  获取我在 jquery 中滚动了多少 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:52.853000             🧑  作者: Mango

代码示例1
//To detect how much the user has scrolled the page vertically in terms of pixels
//from the very top, in JavaScript, we would probe either window.pageYOffset, 
//or in older versions of IE, one of several variants of document.body.scrollTop, 
//whichever property is supported:
var scrollTop = window.pageYOffset || (document.documentElement || document.body.parentNode || document.body).scrollTop

//Using jQuery instead, the equivalent would be:
var scrollTop = $(window).scrollTop() //Best