html代码
<div id="scroll">
滚动内容区域
</div>
js代码
//获取滚动区域
const scroll = document.getElementById("scroll");
scroll.addEventListener("scroll", function(){
// 滚动中的真正的操作
//顶部滚动距离
let scrollTop = item.scrollTop;
//可视区域高度
let clientHeight = item.clientHeight;
//内容的高度
let scrollHeight = item.scrollHeight;
if (scrollTop + clientHeight >= scrollHeight) {
console.log("到底了");
//需要进行的操作--配合防抖函数使用
}
});