开发者

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

I'm using this at the moment:

$(window).scroll(func开发者_运维知识库tion() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
      $(".initial").delay(2000).fadeOut("slow", function() {
          $(".secondary").fadeIn("slow");
      });
    }
});

And I've tried fiddling around with window and replacing it with div names and static pixel values for the scroll to no avail.


Yes. Replace $(document).height() by ($(elem).offset().top+$(elem).outerHeight())

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜