1 var page = 2; //默认展示第一页,所以加载更多从第二页开始 2 var $boxDiv; //所有内容的外层DIV 3 $(document).ready(function() { 4 $boxDiv = $("#commentDiv"); 5 6 var nScrollHight = 0; // 滚动距离总长(注意不是滚动条的长度) 7 var nScrollTop = 0; // 滚动到的当前位置 8 var nDivHight = $boxDiv.height(); 9 10 //jQuery scroll方法 11 $boxDiv.scroll(function() { 12 nScrollHight = $(this)[0].scrollHeight; 13 nScrollTop = $(this)[0].scrollTop; 14 15 if (nScrollTop + nDivHight >= nScrollHight) { 16 //显示更多 17 showMore(page); 18 page = page + 1 ; 19 } 20 }); 21 }); 22 23 function showMore(page){ 24 var data = '&nPageIndex='+page; 25 var url = "/showcomment/getMoreComments.do?iddd="+Math.random(); 26 doAjax(url,data,afterGetComments); 27 }
转载于:https://www.cnblogs.com/weilantiankong/p/4704142.html