JS判断滚动条是否已经滚动到底部

  $(function () {
        window.onscroll = function () {
            var clientHeight = document.documentElement.scrollTop == 0 ? document.body.clientHeight : document.documentElement.clientHeight;
            var scrollTop = document.documentElement.scrollTop == 0 ? document.body.scrollTop : document.documentElement.scrollTop;
            var scrollHeight = document.documentElement.scrollTop == 0 ? document.body.scrollHeight : document.documentElement.scrollHeight;
            if (clientHeight + scrollTop == scrollHeight) {
             //滚动到底部后需要做的事情
            }
        }
    })

posted @ 2014-10-11 14:57  zhuweirandy  阅读(114)  评论(0编辑  收藏  举报