0
我能够加载我的ajax当滚动到底部时,我想弄清楚如何修改下面的代码片段,以便它只在窗口滚动时才起作用到顶部?JQuery窗口滚动顶部和底部
$(window).scroll(function() {
if ($(document).height() <= $(window).scrollTop() + $(window).height()) {
//this works here for scrolling bottom
}
else if ($(document).height() >= $(window).scrollTop() + $(window).height()){
//i tried checking for greater than the window scroll but that didn't owrk
}
});
这不会解决问题,为的$(document).height()总是会在这种情况下,最大或同等价值与增加的其他数值相比。所以问题在于if-else-if的条件。 –