獲取元素、瀏覽器、頁面顯示區域(可視區域)的高度:
$('.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'); } });