天天看点

网页滚动条滚动事件

今天在写代码的时候碰到了滚动条事件,这里记录一下,以防忘记

一、整个网页滚动事件 直接贴代码

$(window).scroll(function () {
        if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
            page++;        
            initMessage(page,rows);

        }
    });
           

二、div的滚动条事件

$("#scrollPage").scroll(function(){

         var $this =$(this),  
         viewH =$(this).height(),//可见高度  
         contentH =$(this).get().scrollHeight,//内容高度  
         scrollTop =$(this).scrollTop();//滚动高度  
        if(scrollTop/(contentH -viewH)==){
             page++;
            studentInfo(page,rows);

        }  




     });
           

scrollPage是div的id