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

        /**
         * [滚动条]
         */
        $(window).scroll(function() {
    
            var scrollTop = $(this).scrollTop(); // 滚动条距离顶部的高度
            console.log("滚动条距离顶部的高度-->" + scrollTop);
    
            var scrollHeight = $(document).height(); // 当前页面的总高度
            console.log("当前页面的总高度-->" + scrollHeight);
    
            var clientHeight = $(this).height(); // 当前可视的页面高度
            console.log("当前可视的页面高度-->" + clientHeight);
    
            if (scrollTop + clientHeight >= scrollHeight) { // 距离顶部高度+可视高度 >= 文档总高度 即代表滑动到底部         
    
                // code...
                alert('已经到底了!');
    
            } else if (scrollTop <= 0) {
    
                // code...
                alert('已经到顶了!');
    
            }
    
        });
  • 相关阅读:
    string的sizeof
    计算程序运行时间
    sleep所在头文件
    Mysql复制表结构、表数据
    UIView属性
    UITextView
    UITextField属性
    UISwitch属性
    UISlide属性
    UISegment属性
  • 原文地址:https://www.cnblogs.com/lprosper/p/9673299.html
Copyright © 2011-2022 走看看