检测滚动到DIV的底部 [英] detect scroll to bottom of a DIV

查看:86
本文介绍了检测滚动到DIV的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测到我达到了div
的底部我的div是400px高度,溢出隐藏
i不知道正常高度但超过400px

我使用这段代码但它不起作用
有什么想法?

  if($(#article-txt)。scrollTop()+ $(#article-txt)。height()== $(#article-txt)[0] .scrollHeight){
警报(底部!);
}


解决方案

 <$ c $(this)[0] .scrollHeight  -  $(this).scrollTop()=== $(this).outerHeight()($#$>#parentdiv ()){
alert(1);
};
});

作品。您需要添加父级div名称,而不是滚动Div本身。


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!");
   }

解决方案

$("#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.

这篇关于检测滚动到DIV的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆