JQuery Detect Scroll at Bottom

后端 未结 10 741
南方客
南方客 2021-01-30 09:58

I wish to achieve content load when the user scrolls to the bottom of the page.

I am having a problem. It works fine on desktop browsers but not on mobile. I have imple

10条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 10:09

    Though the question was asked 5 years ago, still it is more than relevant in today's UI/UX context. And I would like to add my two cents.

    var element = document.getElementById('flux');
    if (element.scrollHeight - element.scrollTop === element.clientHeight)
    {
        // element is at the end of its scroll, load more content
    }
    

    Source: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Determine_if_an_element_has_been_totally_scrolled

提交回复
热议问题