<style>
*{margin: 0;padding: 0}
body{
height: 2000px;
background: red;
}
div{
height: 1000px;
background: green;
}
</style>
</head>
<body>
<div></div>
<!-- 判断滚动条是否到达底部 -->
<script>
/* 获取滚动区域的高度 */
/* var scrollHeight = document.documentElement.scrollHeight;
console.log(scrollHeight);
window.onscroll = function(){
var scrollTop = Math.ceil(documentElement.scrollTop);
var availHeight = document.documentElement.clientHeight;
if(scrollTop+availHeight == scrollHeight){
console.log("到达底部")
}
} */
window.onload = function(){
console.log(onReachBotton())
}
</script>
二、jquery-bottom
<style>
body{
height: 2000px;
background: red;
}
</style>
</head>
<body>
<script>
var scrollHeight = $(document).height();
var avaiHeight = $(window).height();
$(window).scroll(function(){
var scrollTop = $(document).scrollTop();
if(avaiHeight+scrollTop==scrollHeight){
console.log("已经到达底部")
}
})
</script>