Detecting when user scrolls to bottom of div with jQuery

前端 未结 15 1939
一个人的身影
一个人的身影 2020-11-22 14:47

I have a div box (called flux) with a variable amount of content inside. This divbox has overflow set to auto.

Now, what I am trying to do, is, when the use scroll t

15条回答
  •  猫巷女王i
    2020-11-22 15:36

    I found a solution that when you scroll your window and end of a div shown from bottom gives you an alert.

    $(window).bind('scroll', function() {
        if($(window).scrollTop() >= $('.posts').offset().top + $('.posts').outerHeight() - window.innerHeight) {
            alert('end reached');
        }
    });
    

    In this example if you scroll down when div (.posts) finish its give you an alert.

提交回复
热议问题