1》全局控制
//向上滑动显示 var initTop = 0; var i = 1; $(window).scroll(function(){ var scrollTop = $(document).scrollTop(); if(scrollTop < initTop){ var top = document.documentElement.scrollTop + document.body.scrollTop; if(top == 0){ i++; showMessage(i,'loadold'); } } initTop = scrollTop; });
2》div滚动
$(".alllist").scroll(function(){ distanceScrollCount = $(this)[0].scrollHeight; distanceScroll = $(this)[0].scrollTop; distanceSum = distanceScroll + divHight + 35; if(distanceSum >= distanceScrollCount){ i++; showMessage(i,'loadold'); } });