$(document).height()和$(window).height()区别

来源:互联网 发布:mac过热 编辑:程序博客网 时间:2024/06/05 17:54

$(window).heigth()指 默认浏览器滚动区域的高度,而$(document).height()指整个文档内容的高度。

而且当浏览器窗口大小改变时(如最大化或拉大窗口后) jQuery(window).height() 随之改变,但是jQuery(document).height()是不变的。



$(document).scrollTop() 获取垂直距离,即当前滚动的地方到整个页面顶端的距离;

$(document).scrollLeft() 这是获取水平滚动条的距离; 
要获取顶端 只需要获取到scrollTop()==0的时候  就是顶端了
要获取底端 只要获取scrollTop()>=$(document).height()-$(window).height()  就可以知道已经滚动到底端了
 





0 0
原创粉丝点击