Home >Web Front-end >JS Tutorial >jquery method to determine whether the scroll bar has reached the bottom or top
$(document).height() //是获取整个页面的高度 $(window).height() //是获取当前也就是浏览器所能看到的页面的那部分的高度。这个大小在你缩放浏览器窗口大小时会改变,与document是不一样的To get the top, you only need to get the top when scrollTop()==0;
To get the bottom, you only need to get scrollTop()>=$(document).height()-$(window). height() You can know that it has scrolled to the bottom;
$(document).scrollTop() 获取垂直滚动的距离 即当前滚动的地方的窗口顶端到整个页面顶端的距离; $(document).scrollLeft() 这是获取水平滚动条的距离;
Example:
$(document).scroll(function(){ $("#lb").text($(document).scrollTop()); }) <span id="lb" style="top:100px;left:100px;position:fixed;"></span><!--一个固定的span标记 滚动时-->More jquery methods to determine whether the scroll bar has reached the bottom or top. For related articles, please pay attention to the PHP Chinese website!