繁体   English   中英

如何使用JQuery检测用户是否滚动到页面底部?

[英]How do I use JQuery to detect if a user scrolls to the bottom of the page?

一旦它触及底部,那么有一个回调函数?

您可以在窗口上以这种方式使用.scroll()事件:

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
       alert("bottom!");
   }
});

检查现场演示

要检测用户是否在页面上3/4,您可以尝试这个

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() > $(document).height() - .75*$(document).height()) {
       alert("3/4th of bottom!");
   }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM