个人随笔
目录
Jquery页面滚动到底部自动加载
2019-02-18 23:03:46

1、html,body{width:100%;height:100%;} 无法触发onscroll和scroll 即jq和js都不会触发scroll事件!
所以,height:100%,必须去掉,否则不会触发scroll事件
2、由以下代码即可

  1. $(window).scroll(function(){
  2. var scrollTop = $(this).scrollTop();
  3. var scrollHeight = $(document).height();
  4. var windowHeight = $(this).height();
  5. console.log("scrollTope:"+scrollTop);//滚动条高度 console.log("scrollHeighte:"+scrollHeight);//文档的总高度 console.log("windowHeighte:"+windowHeight);//可视高度
  6. ///若文档的总高度 和可视高度+滚动高度相同,就加载
  7. if(scrollTop + windowHeight == scrollHeight){
  8. alert("到底部的操作");
  9. }
  10. });
 449

啊!这个可能是世界上最丑的留言输入框功能~


当然,也是最丑的留言列表

有疑问发邮件到 : suibibk@qq.com 侵权立删
Copyright : 个人随笔   备案号 : 粤ICP备18099399号-2