我的if运行了两次,我希望它使用-400只运行一次



my if在上传递帐户时运行两次

所以它是正确的:

$("#listaPGG").scroll(function() { 
if($(this).scrollTop() + $(this).innerHeight() >= this.scrollHeight) {
proximaPagina()
}
});

所以它执行两次:

$("#listaPGG").scroll(function() { 
if($(this).scrollTop() + $(this).innerHeight() >= this.scrollHeight - 400) {
proximaPagina()
}
});

如何使用-400只运行一次?

您可以添加一个变量来检查语句是否已运行:

var scrolled = false;
$("#listaPGG").scroll(function() { 
if($(this).scrollTop() + $(this).innerHeight() >= this.scrollHeight - 400 && !scrolled) {
scrolled = true;
proximaPagina()
}
});

最新更新