<body>
<div id="div1" style="border:1px solid black;width:200px;height:200px;overflow:auto">
第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>第17行<br>第18行<br>第19行<br>第20行
<br>第21行<br>第22行<br>第23行<br>第24行<br>第25行
<br>
<script>
$(function() {
$(div1).scroll(function() {
var scrollTop = $(div1).scrollTop();
var scrollHeight = $(div1).height();
if (scrollTop == 0) {
alert('触顶');
}
if (scrollTop >= scrollHeight) {
alert('到底');
}
})
})
</script>
</div>
</body>
上拉到顶,和下拉到底
最新推荐文章于 2023-11-06 17:32:07 发布