首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

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

2012-08-21 
使用jquery判断鼠标滚动到页面底部$(function(){$(window).scroll(function(){if(arrviedAtBottom()) {//.

使用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;

   }

热点排行