我如何使用jQuery,如果用户滚动检测到页面底部? [英] How do I use JQuery to detect if a user scrolls to the bottom of the page?
本文介绍了我如何使用jQuery,如果用户滚动检测到页面底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
而一旦它击中的底部,然后有一个回调函数?
And once it hits the bottom,then have a callback function?
推荐答案
您可以在窗口上使用.scroll()事件是这样的:
You can use .scroll() event in this way on your window:
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
}
});
来检测用户是否3/4下来页面,您可以试试这个
to detect if the user is 3/4 down the page you can try this one
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - .75*$(document).height()) {
alert("3/4th of bottom!");
}
});
这篇关于我如何使用jQuery,如果用户滚动检测到页面底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文