獲取網頁元素的幾個高度、滾動條高度


獲取元素、瀏覽器、頁面顯示區域(可視區域)的高度:

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