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

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

$('.class').height();

$(window).height();

$(document).height(); 

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

$('.class').scrollTop();

$(window).scrollTop();  

$(document).scrollTop();  

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

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

$(document).innerHeight;

扫描二维码关注公众号,回复: 11161001 查看本文章

$(window).innerHeight;

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

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

猜你喜欢

转载自www.cnblogs.com/feiying100/p/12812699.html
今日推荐