滚动条滚动到最底部

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="content-type" content="text/html" />
	<meta name="author" content="Steve Smith" />
    <script src="/static/js/common/jquery.js"></script>
	<title>无标题 1</title>
</head>


<body>
<script>


jQuery(document).ready(function () {
 
    $("#test").bind("resize", function(){ //绑定事件 


    }).bind("scroll", function(){ 
        var scroll = $(this).scrollTop();//获得滚动条卷起来的高度值
        var scrollHeight = $("#test")[0].scrollHeight - $("#test")[0].clientHeight;//滚动内容实际高度 - 可视区域高度
      
        if (scroll == scrollHeight) {
            alert('到底部了')
        }
       
    });
    
    
    $("#sb").bind("click", function (){
         $("#test").scrollTop($("#test")[0].scrollHeight)
    })
});


</script>
<div id="sb">滚动底部</div>
<div id="test" style="overflow-y: auto; height:200px; border:1px solid red">
测试测试1<br />
测试测试2<br />
测试测试3<br />
测试测试4<br />
测试测试5<br />
测试测试6<br />
测试测试7<br />
测试测试8<br />
测试测试9<br />
测试测试10<br />
测试测试11<br />
测试测试12<br />
测试测试13<br />
测试测试14<br />
测试测试15<br />
测试测试16<br />
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值