2

I have a problem with infinite scrolling... This is the code:

<script>
    $(window).scroll(function() {
       if($(window).scrollTop() + $(window).height() == $(document).height()) {
           alert("test");
       }
    });
  </script>

It alerts when user hits the top of the page, not the bottom. I can't figure out where the problem is. Thanks is advance.

Funk Forty Niner
  • 73,764
  • 15
  • 63
  • 131
SomeName
  • 25
  • 5

1 Answers1

0
      $(window).scroll(function(){
                if  ($(window).scrollTop() == $(document).height() - $(window).height()){
                     alert("test");
                }
           }); 

Here it alerts "test" when you hit the bottom of the page..

fiddle: https://jsfiddle.net/845k1c2b/

Hope this helps!

Krishna Kamal
  • 124
  • 1
  • 7