开发者

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

开发者 https://www.devze.com 2023-04-02 20:33 出处:网络
I\'m using this at the moment: $(window).scroll(func开发者_运维知识库tion() { if($(window).scrollTop() + $(window).height() == $(document).height()) {

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

精彩评论

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