Jquery发现div是否在滚动时到达底部

use*_*424 2 html css php jquery content-management-system

我不能得到这个工作,有什么问题?

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

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

发生的事情是我需要再次向上滚动才能检测到它到达底部.

joh*_*les 5

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

$("span").hide();

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