首页 > Web开发 > 详细

获取网页元素的几个高度、滚动条高度

时间:2020-05-01 11:06:09      阅读:183      评论:0      收藏:0      [点我收藏+]

获取元素、浏览器、页面显示区域(可视区域)的高度:

$(‘.class‘).height();

$(window).height();

$(document).height(); 

获取元素、浏览器、页面 的滚动条到顶部的垂直高度:

$(‘.class‘).scrollTop();

$(window).scrollTop();  

$(document).scrollTop();  

获取元素、浏览器、页面 的包含滚动条的垂直高度:

$(‘.class‘)[0].scrollHeight 或者 document.getElementById("id").scrollHeight;

$(document).innerHeight;

$(window).innerHeight;

 

示例:判断容器滚动条,滚到底部,代码:

    $(.class).scroll(function(){
        
        if( $(this).height() + $(this).scrollTop() == $(this)[0].scrollHeight ){
            alert(bottom);
        }
        
    });

 

获取网页元素的几个高度、滚动条高度

原文:https://www.cnblogs.com/feiying100/p/12812699.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!