
//<!-- 页面滚动动态加载数据,页面下拉自动加载内容 -->
$(window).scroll(function(){
totalheight =parseFloat($(window).scrollTop())+ parseFloat($(window).height());
if(($(document).height()/2) <= totalheight ) { //有滚动条 且滚动到触发点(一半)
next();
}
});
$(window).on('mousewheel', function(event) { //手机不支持
totalheight =parseFloat($(window).scrollTop())+ parseFloat($(window).height());
if(totalheight==$(document).height()) //无滚动条
{
if(event.originalEvent.wheelDelta<0) //且 向下滚动
next();
}
});
本文介绍了一种使用jQuery实现的页面滚动动态加载数据的方法。当用户滚动到页面一半时,自动触发内容加载,增强用户体验。同时,针对不同设备,如手机和平板,提供了相应的滚动事件监听。
1468

被折叠的 条评论
为什么被折叠?



