繁体   English   中英

当用户滚动到页面底部时,如何启动jQuery事件?

[英]How to start a jQuery event when the user scrolls to the bottom of the page?

我正在尝试获取警报,以显示用户是否在页面底部100像素内滚动。 我正在让/ friends加载到div class = social,但是在滚动部分上遇到了麻烦。 关于我可以解决的任何建议吗?

<!--Load friends module -->
<script>
  $(document).ready(function (){
    $('.social').load("/friends");
  });
</script>
<!--Load more videos if scroll within 100 pixels of bottom -->
<script type="text/javascript">
  counter = 2;
  $(document).ready(function (){
    function loadMore() {
      console.log("More loaded");
      alert("test");
      $('.more_videos').load("/more_videos/"+counter);
      $(window).bind('scroll', bindScroll);
    }
    function bindScroll(){
      if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
        $(window).unbind('scroll');
        loadMore();
      }
    }
    $(window).scroll(bindScroll);​
  });
  counter = counter+1;
</script>

此行后有一个看不见的字符

$(window).scroll(bindScroll); 

你可以在这里看到它。 这是第20行结尾处的小红点

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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