$(document).height();//文档高度
$(window).height();//是文档窗口高度
$(“div”).offset().top//是标签距离顶部高度
(window).scrollTop();//是滚动条高度和(window).scrollTop();//是滚动条高度 和(window).scrollTop();//是滚动条高度和(document).scrollTop()效果一样 但是$(window).scrollTop() 兼容性好
$(".footer").height();//是标签高度
$(window).height() 和 $(document).height()的区别
$(document).scrollTop() 获取垂直滚动的距离 (即当前滚动的地方的窗口顶端到整个页面顶端的距离)
(document).scrollLeft()这是获取水平滚动条的距离要获取顶端只需要获取到scrollTop()==0的时候就是顶端了要获取底端只要获取scrollTop()>=(document).scrollLeft() 这是获取水平滚动条的距离
要获取顶端 只需要获取到scrollTop()==0的时候 就是顶端了
要获取底端 只要获取scrollTop()>=(document).scrollLeft()这是获取水平滚动条的距离要获取顶端只需要获取到scrollTop()==0的时候就是顶端了要获取底端只要获取scrollTop()>=(document).height()-$(window).height()
就可以知道已经滚动到底端了
注意:(window).height() 和 (window).height() 和 (window).height() 和 (document).height()的区别
jQuery(window).height()代表了当前可见区域的大小,
jQuery(document).height()则代表了整个文档的高度,可视具体情况使用.
注意:当浏览器窗口大小改变时(如最大化或拉大窗口后) ,
jQuery(window).height() 随之改变,但是
jQuery(document).height()是不变的。
function scrollToEnd(){//滚动到底部
var h = (document).height()−(document).height()-(document).height()−(window).height();
$(document).scrollTop(h);
}