我想在滚动到达页面底部时发出警告,如下所示:
$(function(){
$(document).scroll(function() {
if($(document).scrollTop() == 0) alert("top");
})
})
但没有 jQuery,到达底部时发出警报。
最佳答案
document.addEventListener('scroll', function (event) {
if (document.body.scrollHeight ==
document.body.scrollTop +
window.innerHeight) {
alert("Bottom!");
}
});
JSFiddle 在这里:http://jsfiddle.net/cSer6/
关于javascript - 检测 Scroll 何时到达页面的底部 [没有 jQuery],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10059888/