zoukankan      html  css  js  c++  java
  • 判断滚动条滚到底部

    原理:文档高度 = 视口高度 + 滚动条高度

    1.若是一整个浏览窗口的滚动条:

    $(window).scroll(function () {
    var documentHeight = $(document).height();//1188
    var windowHeight = $(window).height();//706
    var scrollTop = $(document).scrollTop();//482
    var sh = windowHeight + scrollTop ;
    console.log("sh="+sh+"documentHeight="+documentHeight);
        if(windowHeight+scrollTop ==  documentHeight){
    //滚动到底部
    }
    });
    或者
    $(document).scroll(function () {
    var documentHeight = $(document).height();//1188
    var windowHeight = $(window).height();//706
    var scrollTop = $(document).scrollTop();//482
    var sh = windowHeight + scrollTop ;
    console.log("sh="+sh+"documentHeight="+documentHeight);
        if(windowHeight+scrollTop ==  documentHeight){
    //滚动到底部
    }

    });
    2.若是某个div的滚动条:
    $(document).ready(function () {
    $(".tongModalBox").scroll(function () {
    var documentHeight = $(this).prop('scrollHeight');//或$(this)[0].scrollHeight
    var windowHeight = $(this).height();
    var scrollTop = $(this).scrollTop();
    var sh = windowHeight + scrollTop ;
    console.log("sh="+sh+"documentHeight="+documentHeight);
            if(windowHeight+scrollTop ==  documentHeight){
    //滚动到底部
    }

    });
    });
  • 相关阅读:
    11.13 同步异步协程
    GIL及进程池
    线程
    守护进程-互斥锁-IPC
    进程
    网络编程
    异常的处理
    面向对象编程2
    第一章 python学习,个人对计算机硬件的一些理解
    ActiveReports之直接打印报表
  • 原文地址:https://www.cnblogs.com/yuyedaocao/p/9970827.html
Copyright © 2011-2022 走看看