Infinite scrollable jquery not working

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 warns when the user hits the top of the page, not the bottom. I can't figure out where the problem is. Thanks in advance.

+2


source to share


1 answer


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

      

Here it warns "test" when you get to the bottom of the page.



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

Hope this helps!

0


source







All Articles