首页 > 代码库 > 网页滚动到底部,拉取数据
网页滚动到底部,拉取数据
网页滚动模式
//滚到到底部自动拉取数据 //页面滚到底部异步加载下一页数据 $(window).scroll(function () { //已经滚动到上面的页面高度 var scrollTop = parseFloat($(this).scrollTop()), //页面高度 scrollHeight = $(document).height(), //浏览器窗口高度 windowHeight = parseFloat($(this).height()), totalHeight = scrollTop + windowHeight; //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作 if (scrollTop + windowHeight >= scrollHeight - 0.7) { var index = $(‘.swiper-slide-active‘).data("index"); var id = $(‘.swiper-slide-active‘).attr("id"); eval(‘‘+id+‘(‘+Number(index)+1+‘,‘+pageNumber+‘,"‘+userid+‘")‘); } });
可滚动的元素 ,滚动到底部,触发获取数据
//滚到到底部自动拉取数据 //页面滚到底部异步加载下一页数据 $(".swiper-slide").scroll(function () { //已经滚动到上面的页面高度 var scrollTop = parseFloat($(this).scrollTop()), //滚动高度 scrollHeight = this.scrollHeight, //窗口高度 windowHeight = $(this).height(), totalHeight = scrollTop + windowHeight; //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作 if (scrollTop + windowHeight >= scrollHeight - 0.7) { console.log("==="); var nextIndex = Number($(‘.swiper-slide-active‘).data("index"))+1; var id = $(‘.swiper-slide-active‘).attr("id"); eval(‘‘ + id + ‘(‘ + nextIndex + ‘,‘ + pageNumber + ‘,"‘ + userid + ‘")‘); } });
网页滚动到底部,拉取数据
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。