1 //滚动到底部加载数据 2 $(window).scroll(function () { 3 var scrollTop = $(this).scrollTop(); 4 var elementHeight = $(this).height(); 5 var h1 = scrollTop + elementHeight; 6 var scrollHeight = document.documentElement.scrollHeight;
//var documentHeight = $(document).height(); 7 if (h1 >= scrollHeight) { 8 var pageIndex = $("#hidPageIndex").val(); 9 AppendNews(pageIndex); //加载新数据 10 } 11 });
说明:
document.documentElement.scrollHeight 等效于 $(document).height()