且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery窗口滚动事件未触发

更新时间:2023-08-18 19:15:04

您的CSS实际上正在将文档的其余部分设置为不显示溢出,因此文档本身不会滚动.最简单的解决方法是将事件绑定到正在滚动的对象,在您的情况下为div#page.

Your CSS is actually setting the rest of the document to not show overflow therefore the document itself isn't scrolling. The easiest fix for this is bind the event to the thing that is scrolling, which in your case is div#page.

所以它很容易更改:

$(document).scroll(function() {  // OR  $(window).scroll(function() {
    didScroll = true;
});

$('div#page').scroll(function() {
    didScroll = true;
});