Jquery find if div reached the bottom on scroll

非 Y 不嫁゛ 提交于 2019-12-08 03:43:41

问题


I cant get this tot work, what is the problem?

$("#scrollingbox").scroll(function() { //detect page scroll

    if($("#scrollingbox").scrollTop() + $("#scrollingbox").height() == $("#scrollingbox").height())  //user scrolled to bottom of the page?
    {
            //do something
        }
 }

what happens is i need to scroll up again for it to detect that it reached the bottom.


回答1:


http://jsfiddle.net/collabcoders/v2RbN/1/

$("span").hide();

$(".box").scroll(function() {
    if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
        $("span").show();    
    } else {
        $("span").hide();
    }
})


来源:https://stackoverflow.com/questions/21212051/jquery-find-if-div-reached-the-bottom-on-scroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!