公告
财富商城
积分规则
提问
发文
2019-01-07 04:10发布
Melony?
I have a div layer with overflow set to scroll.
div
overflow
scroll
When scrolled to the bottom of the div, I wanna run a function.
Since innerHeight doesn't work in some old IE versions, clientHeight can be used:
innerHeight
clientHeight
$(window).scroll(function (e){ var body = document.body; //alert (body.clientHeight); var scrollTop = this.pageYOffset || body.scrollTop; if (body.scrollHeight - scrollTop === parseFloat(body.clientHeight)) { loadMoreNews(); } });
I could not get either of the above answers to work so here is a third option that works for me! (This is used with jQuery)
if (($(window).innerHeight() + $(window).scrollTop()) >= $("body").height()) { //do stuff }
Hope this helps anyone!
最多设置5个标签!
Since
innerHeight
doesn't work in some old IE versions,clientHeight
can be used:I could not get either of the above answers to work so here is a third option that works for me! (This is used with jQuery)
Hope this helps anyone!