码迷,mamicode.com
首页 > 其他好文 > 详细

页面滚动条滑动至底部加载信息

时间:2018-07-27 12:03:00      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:console   滑动   html   height   append   需要   this   end   nbsp   

$(window).scroll(function(){
 
  var scrollTop = $(this).scrollTop();    //滚动条距离顶部的高度
  var scrollHeight = $(document).height();   //当前页面的总高度
  var clientHeight = $(this).height();    //当前可视的页面高度
  // console.log("top:"+scrollTop+",doc:"+scrollHeight+",client:"+clientHeight);
  if(scrollTop + clientHeight >= scrollHeight){   //距离顶部+当前高度 >=文档总高度 即代表滑动到底部 
      var html=‘‘;//需要添加的数据信息
      
      $(‘.masonry‘).append(html);//添加到哪里去    
  }
});

页面滚动条滑动至底部加载信息

标签:console   滑动   html   height   append   需要   this   end   nbsp   

原文地址:https://www.cnblogs.com/zhangyong0908/p/9376493.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!