无限滚动jquery无法正常工作 [英] Infinite scrolling jquery not working
本文介绍了无限滚动jquery无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有无限滚动的问题...这是代码:
I have a problem with infinite scrolling... This is the code:
<script>
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("test");
}
});
</script>
当用户点击页面顶部而不是底部时会发出警报。我无法弄清楚问题出在哪里。谢谢你的提前。
It alerts when user hits the top of the page, not the bottom. I can't figure out where the problem is. Thanks is advance.
推荐答案
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
alert("test");
}
});
当你点击页面底部时,它会提醒test..
Here it alerts "test" when you hit the bottom of the page..
小提琴: https://jsfiddle.net/845k1c2b/
希望这会有所帮助!
这篇关于无限滚动jquery无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文