想通过这个点击按钮加载更多数据,却不能控制它的隐藏,怎么解决?
function scrollFunc(e) {
e = e || window.event;
if (e.wheelDelta) { //第一步:先判断浏览器IE,谷歌滑轮事件
if (e.wheelDelta > 0) { //当滑轮向上滚动时
console.log("滑轮向上滚动");
$(".loadMore").hide();
}
if (e.wheelDelta < 0) { //当滑轮向下滚动时
console.log("滑轮向下滚动");
$(".loadMore").show();
}
} else if (e.detail) { //Firefox滑轮事件
if (e.detail> 0) { //当滑轮向上滚动时
console.log("滑轮向上滚动");
$(".loadMore").hide();
}
if (e.detail< 0) { //当滑轮向下滚动时
console.log("滑轮向下滚动");
if($(window).scrollTop()+$(window).height()==$(document).height()){
$(".loadMore").show();
}
}
}
}
}
下面代码中,size为每次点击请求的数据条数,sum为每次点击后返回的数据条数
if(size>sum){
if((offset*size)>sum){
$(".loadMore").hide();
}else{
$(".loadMore").show();
}
现在问题是:当点击后没有更多数据时,需隐藏加载更多按钮,但是这2段代码功能有点冲突