知道垂直滚动条在div中滚动的底部 [英] Know when vertical scrollbar hits bottom of scroll in div

查看:93
本文介绍了知道垂直滚动条在div中滚动的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $(#divID)。scroll(function() {
if($(#divID)。scrollTop()== $(#divID)。height() - $(#divID)。offset()。top){
alert(1);
}
});

divID 是div的id。

解决方案

  $(#divID)。scroll(function(){
$ if($)(this).scrollTop()< = $(this).outerHeight())
{
alert(1);
}
});

演示: http://jsfiddle.net/AlienWebguy/DgYcY/


I used following code but it is not working:

$("#divID").scroll(function(){
        if  ($("#divID").scrollTop() == $("#divID").height() - $("#divID").offset().top){
           alert(1);
        }
    });

divID is the id of div.

解决方案

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

Demo: http://jsfiddle.net/AlienWebguy/DgYcY/

这篇关于知道垂直滚动条在div中滚动的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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