繁体   English   中英

JS是否有办法检测到div的底部而不是页面的底部?

[英]Is there a way for JS to detect that the bottom of a div has been reached, rather than the bottom of a page?

我现在正在使用这个:

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
      $(".initial").delay(2000).fadeOut("slow", function() {
          $(".secondary").fadeIn("slow");
      });
    }
});

而且我尝试摆弄window并用div名称和静态像素值替换它,以至于无济于事。

是。 更换$(document).height()( $(elem).offset().top + $(elem).outerHeight() )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM