jQuery滚动条滑动到底部时触发事件,加载数据,如何实现呢?
$(window).scroll(function(){
var scrollTop = $(this).scrollTop();//返回匹配元素的滚动条的垂直位置
var scrollHeight = $(document).height();//代表了整个文档的高度
var windowHeight = $(this).height();//代表了当前可见区域的大小
if(scrollTop + windowHeight == scrollHeight){
加载数据
}else{
数据加载完毕!
}我的为什么不是想要的效果呢?