我有下面的 Javascript,当滚动条到达页面底部时,警报就会按预期显示。
但是,我希望这发生在 100 像素处before它到达底部。我该怎么做呢?
$(window).scroll(function(){
if($(window).scrollTop() == $(document).height() - $(window).height() ){
alert("at bottom");
}
}
$(window).scroll(function(){
if($(window).scrollTop() + 100 > $(document).height() - $(window).height() ){
alert("at bottom");
}
});
Using >
代替==
因为滚动事件偶尔会触发,所以您可能会多次滚动超过该值,而当存在精确匹配时,事件不会触发。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)