您的位置:首页 > Web前端 > JavaScript

js 判断是否滚动到底部

2017-04-19 16:22 639 查看
$(window).scroll(function(){
var scrollTop = $(this).scrollTop();  //scrollTop() 方法返回或设置匹配元素的滚动条的垂直位置
var scrollHeight = $(document).height(); //整个文档的高度
var windowHeight = $(this).height(); //当前可见区域的大小
if(scrollTop + windowHeight == scrollHeight){
alert('The page has been scrolled to the bottom')
}
})


当 html,body{width:100%;height:100%;} 绑定在window或者body无法触发onscroll和scroll 即jq和js都不会触发scroll事件!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: