js 判断是否滚动到底部

            $(window).scroll(function(){
                var scrollTop = $(this).scrollTop();  //scrollTop() 方法返回或设置匹配元素的滚动条的垂直位置
                var scrollHeight = $(document).height(); //整个文档的高度
                var windowHeight = $(this).height(); //当前可见区域的大小
                if(scrollTop + windowHeight == scrollHeight){
                    alert('The page has been scrolled to the bottom')
                }
            })

 当 html,body{width:100%;height:100%;}  绑定在window或者body无法触发onscroll和scroll  即jq和js都不会触发scroll事件!

posted @ 2017-04-19 16:22  AllenChou  阅读(2228)  评论(0编辑  收藏  举报