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


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

$('.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');
        }
        
    });

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM