Php Jquery find if div到达滚动条的底部

Php Jquery find if div到达滚动条的底部,php,jquery,html,css,content-management-system,Php,Jquery,Html,Css,Content Management System,我不能让这玩意儿工作,有什么问题吗 $("#scrollingbox").scroll(function() { //detect page scroll if($("#scrollingbox").scrollTop() + $("#scrollingbox").height() == $("#scrollingbox").height()) //user scrolled to bottom of the page? { //do somethin

我不能让这玩意儿工作,有什么问题吗

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

    if($("#scrollingbox").scrollTop() + $("#scrollingbox").height() == $("#scrollingbox").height())  //user scrolled to bottom of the page?
    {
            //do something
        }
 }
发生的事情是我需要再次向上滚动,以检测它是否到达底部。


如果要使用DOM方法,不要创建jQuery对象,然后将其丢弃,只需使用DOM:
this.scrollHeight
(而不是
$(this)[0]。scrollHeight
),另外:如果重复使用变量,请缓存它们。scrollTop始终>=0。所以本质上你是在问,如果某个总是>=0+X的东西等于X,当scroll=0时,这个条件就是真的。即,未完成滚动时。您可以看到,这与探测到达底部不同。
$("span").hide();

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