天天看点

jQuery初学——7-scrollLeft-scrollTopscrollLeft(), scrollTop()

scrollLeft(), scrollTop()

获取滚动条位置

实现自动滚动:

var timer = setInterval(function(){
   //判断当前是否到最底端
   //$(document).scrollTop() 滚动的距离;
   //$(window).height() 视图高度;
   //$(document).height() 文档高度
   if($(document).scrollTop() + $(window).height() < $(document).height()){
      var top = $(document).scrollTop();
      $(document).scrollTop( top + 2 );
   }else{
       clearInterval(timer);
    }
},100);