zoukankan      html  css  js  c++  java
  • jquery实现滚动到页面底部时无限加载内容的代码

    1. var p="{$other.p}";  
    2. if(p=="") p=1;  
    3.  var stop=true;//触发开关,防止多次调用事件  
    4.  $(window).scroll(function() {    
    5.       //当内容滚动到底部时加载新的内容 100当距离最底部100个像素时开始加载.  
    6.       if ($(this).scrollTop() + $(window).height() + 100 >= $(document).height() && $(this).scrollTop() > 100) {    
    7.             
    8.           if(stop==true){  
    9.               stop=false;  
    10.               p=p+1;//当前要加载的页码    
    11.               canshu="?t={$other.t}&p="+p+"&cid={$other.cid}";  
    12.                //加载提示信息  
    13.                $("#showlists").append("<li class='ajaxtips'><div style='font-size:2em'>Loding.....</div></li>");  
    14.                $.get("__URL__/nextpage"+canshu,function(data){  
    15.                    $(".ajaxtips").hide();  
    16.                    $("#showlists").append(data);//把新的内容加载到内容的后面  
    17.                    stop=true;  
    18.                })  
    19.          }  
    20.       }    
    21.   });   
     
     
  • 相关阅读:
    hdu-3001 三进制状态压缩+dp
    最长公共子序列(LCS)
    矩阵最优路线DP
    CF-721C DAG图拓扑排序+费用DP
    拓扑排序
    BFS+二进制状态压缩 hdu-1429
    DAG最长路问题 hdu-1224
    并查集-解决区间和纠错问题 hdu-3038
    hdu 4972 根据每轮篮球赛分差求结果
    hdu 1116 欧拉回路+并查集
  • 原文地址:https://www.cnblogs.com/yzadd/p/6495336.html
Copyright © 2011-2022 走看看