滚动到页面底部,更新数据

scrollBottomTest = function() {
$(".main").scroll(function() {
var $this = $(this),
viewH = $(this).height(), //可见高度
contentH = $(this).get(0).scrollHeight, //内容高度
scrollTop = $(this).scrollTop(); //滚动高度
//if(contentH - viewH - scrollTop <= 100) { //到达底部100px时,加载新内容
if(scrollTop / (contentH - viewH) >= 0.95) { //到达底部100px时,加载新内容
$(".main").append("<div class='loadstyle c969696'>加载中...</div>");
console.log("加载");

// 这里加载数据..
//如果加载成功
// $(".loadstyle").remove();
}
});
}
scrollBottomTest();

原文地址:https://www.cnblogs.com/peijunma/p/6511091.html