网页滚动条滚动事件

来源:互联网 发布:淘宝产品市场调查表 编辑:程序博客网 时间:2024/05/22 03:04

今天在写代码的时候碰到了滚动条事件,这里记录一下,以防忘记
一、整个网页滚动事件 直接贴代码

 $(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(0).scrollHeight,//内容高度           scrollTop =$(this).scrollTop();//滚动高度          if(scrollTop/(contentH -viewH)==1){             page++;            studentInfo(page,rows);        }       });

scrollPage是div的id

原创粉丝点击