简体   繁体   中英

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

      $(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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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