一旦它觸及底部,然後有一個回調函數?如何使用JQuery檢測用戶是否滾動到頁面的底部?
6
A
回答
25
可以以這種方式使用.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!");
}
});
http://stackoverflow.com/questions/3962558/javascript-detect-scroll-end – 2012-03-14 07:50:53
檢查這個http://stackoverflow.com/questions/3962558/javascript-detect-scroll-end – Gopesh 2012-03-14 07:57:47
[如何檢查用戶是否滾動到底部]的可能重複(http://stackoverflow.com/questions/3898130/how-to-check-if-a-user-has-scrolled-to-the-底部) – csharpfolk 2014-05-03 06:45:26