`

使用jquery判断鼠标滚动到页面底部

 
阅读更多
$(function(){
    $(window).scroll(function(){
        if(arrviedAtBottom()) {
            //...已到达最底部
        }
    });

    var arrivedAtBottom = function () {
        return $(document).scrollTop() + $(window).height() == $(document).height();
    }
});

另转载@龙城野火提供的原生js写法(原文链接:http://blog.sina.com.cn/s/blog_4b67d3240100rhkh.html):



function reachBottom() {



   var scrollTop = 0;

   var clientHeight = 0;

   var scrollHeight = 0;



   if (document.documentElement && document.documentElement.scrollTop) {

       scrollTop = document.documentElement.scrollTop;

   } else if (document.body) {

       scrollTop = document.body.scrollTop;

   }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics