Javascript 滚动到页面底部和无限滚动

Javascript 滚动到页面底部和无限滚动,javascript,jquery,scroll,Javascript,Jquery,Scroll,我正在尝试制作一个可以无限滚动的网页。现在的问题是,它现在似乎不起作用: window.scroll(function() { alert('Scrolling'); if ($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight()) { alert('Reached the bottom'); } }); 我对jquery真的很陌生,尽管它本质上

我正在尝试制作一个可以无限滚动的网页。现在的问题是,它现在似乎不起作用:

    window.scroll(function() {
    alert('Scrolling');
    if ($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight()) {
            alert('Reached the bottom');
    }
    });

我对jquery真的很陌生,尽管它本质上是javascript(对吗?),但我做错了什么?我还尝试了document.scroll和document.body.scroll

您至少有一个错误。尝试:

 $(window).scroll(function() {
    alert('Scrolling');
    if ($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight()) {
            alert('Reached the bottom');
    }
    });

您至少有一个错误。尝试:

 $(window).scroll(function() {
    alert('Scrolling');
    if ($(this)[0].scrollHeight - $(this).scrollTop() == $(this).outerHeight()) {
            alert('Reached the bottom');
    }
    });
试试这个:

 if ($(this).scrollTop() ==  $(document).height() - $(window).height()) {
            alert('Reached the bottom');
    }
我跳过了它,它就工作了:

试试这个:

 if ($(this).scrollTop() ==  $(document).height() - $(window).height()) {
            alert('Reached the bottom');
    }

我跳过了它,它就成功了:

我想这就是你想要实现的目标:

$(window).scroll(function() {
  if ($('body').scrollTop() + $(window).height() == $('body').outerHeight()) {
    alert('Reached the bottom');
  }
});

我认为这就是你想要实现的目标:

$(window).scroll(function() {
  if ($('body').scrollTop() + $(window).height() == $('body').outerHeight()) {
    alert('Reached the bottom');
  }
});
对我来说就是这样


对我来说就是这样。

好的,现在它意识到它正在滚动,谢谢。现在,我们需要弄清楚如何解决“到达底部”的问题。我刚意识到我放了“这个”。呃。我试过了,它什么也没做。好了,现在它意识到它在滚动,谢谢。现在,我们需要弄清楚如何解决“到达底部”的问题。我刚意识到我放了“这个”。呃。我试过了,它什么也没做。为什么-1这个完全符合这个人的要求。。。来吧,为什么-1这正是人们要求的。。。来吧