移动端,监听div元素的滚动到底部
不说废话,直接上代码
#scrollBox{
position: fixed;
top: 206px;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
}
<div id="scrollBox">
<div id="modBox">
</div>
</div>
// An highlighted block
document.querySelector('#scrollBox).addEventListener('scroll', divScrollEv, true)
function divScrollEv() {
var scrollHeight = document.querySelector('#scrollBox).scrollHeight;//251
var scrollTop = document.querySelector('#scrollBox).scrollTop;//0-18
var clientHeight = document.querySelector('#scrollBox).clientHeight;//233
if (scrollHeight - clientHeight <= (scrollTop+3)) {
//滚动条滚到最底部
}
}
}