如何检测div滚动条何时向上滚动并击中顶部(仅当它击中顶部时)
我找到了另一篇文章,但这篇文章被击中了底部。
我需要的是达到顶峰。有谁知道如何改变这个?
$("#divID").scroll(function(){
if($(this)[0].scrollHeight - $(this).scrollTop() <= $(this).outerHeight())
{
alert(1);
}
});
如何检测div滚动条何时向上滚动并击中顶部(仅当它击中顶部时)
我找到了另一篇文章,但这篇文章被击中了底部。
我需要的是达到顶峰。有谁知道如何改变这个?
$("#divID").scroll(function(){
if($(this)[0].scrollHeight - $(this).scrollTop() <= $(this).outerHeight())
{
alert(1);
}
});
var el = $('.test');
el.on('scroll', function(){
if(el.scrollTop() == 0){alert("i just hit the top")}
});
scrollTop
将0
在滚动条位于顶部时。尝试这个:
$("#divID").scroll(function () {
if ($(this).scrollTop() == 0) {
alert(1);
}
});
$("#divID").scroll(function(){
if($(this)[0].scrollHeight - $(this).scrollTop() <= $(this).outerHeight())
{
alert("Bottom");
}
if($(this).scrollTop() == 0)
{
alert("Top");
}
});
小提琴在这里