detect scroll to bottom of a DIV

2019-07-04 21:41发布

i want to detect that i reach the bottom of a div my div is 400px height with overflow hidden i don't know the normal height but more than 400px

i'm using this code but it doesn't work any idea?

if($("#article-txt").scrollTop() + $("#article-txt").height() == $("#article-txt")[0].scrollHeight) {
       alert("bottom!");
   }

1条回答
啃猪蹄的小仙女
2楼-- · 2019-07-04 22:18
$("#parentdiv").scroll(function(){
    if($(this)[0].scrollHeight - $(this).scrollTop() === $(this).outerHeight()) {
        alert(1);
    };
});

Works. You need to add the parent div name, not the scrolling Div itself.

查看更多
登录 后发表回答