3 回答

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊
.scroll()
window
$(window).scroll(function() { if($(window).scrollTop() + $(window).height() == $(document).height()) { alert("bottom!"); }});
document
$(window).scroll(function() { if($(window).scrollTop() + $(window).height() > $(document).height() - 100) { alert("near bottom!"); }});
100

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊
$(document).height()
function getDocHeight() { var D = document; return Math.max( D.body.scrollHeight, D.documentElement.scrollHeight, D.body.offsetHeight, D.documentElement.offsetHeight, D.body.clientHeight, D.documentElement.clientHeight );}
$(document).height()
$(window).scroll(function() { if($(window).scrollTop() + $(window).height() == getDocHeight()) { alert("bottom!"); } });

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超4個(gè)贊
element.scrollHeight - element.scrollTop === element.clientHeight
element.addEventListener('scroll', function(event){ var element = event.target; if (element.scrollHeight - element.scrollTop === element.clientHeight) { console.log('scrolled'); }});
scrollHeight
clientHeight
scrollTop
添加回答
舉報(bào)