Detect scroll to bottom of DIV

I want to detect that I am getting to the bottom of the div my div is 400px height with overflow I don't know the normal height but over 400px

I am using this code but it doesn't work any idea?

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

      

+3


source to share


1 answer


$("#parentdiv").scroll(function(){
    if($(this)[0].scrollHeight - $(this).scrollTop() === $(this).outerHeight()) {
        alert(1);
    };
});

      



Works. You need to add the parent div name and not scroll the Div yourself.

+5


source







All Articles