移动端上滑加载更多

https://blog.csdn.net/qq_37415950/article/details/80625391

<script >
    /*第一种*/
    $(function(){
 
        $(window).scroll(function(){
 
            var scrollH = document.documentElement.scrollHeight;
 
            var clientH = document.documentElement.clientHeight;
            if (scrollH == (document.documentElement.scrollTop | document.body.scrollTop) + clientH){
                //加载新数据
 
                alert("加载新数据");
 
            }
        });
 
    });
    /*第二中 */
    //获取当前浏览器中的滚动事件
    $(window).off("scroll").on("scroll", function () {
 
        var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; //获取当前浏览器的滚动条高度
 
        if (scrollHeight <= ($(window).scrollTop() + $(window).height())) { //判断当前浏览器滚动条高度是否已到达浏览器底部,如果到达底部加载下一页数据信息
            $("#loadingImg").css('visibility','visible');
            setTimeout(function () {
 
               
                //模拟ajax
                for(m=0;m<5;m++){
                    $(".order-list").append(appendStr);
                }
                
            },1000)
        }
    });
 
</script>

猜你喜欢

转载自www.cnblogs.com/gavinyyb/p/9986833.html