jq获取滚动条高度

获取浏览器显示区域的高度 : $(window).height();浏览器

 

获取浏览器显示区域的宽度 :$(window).width();文档

 

获取页面的文档高度 :$(document).height();io

 

获取页面的文档宽度 :$(document).width();cli

 

获取滚动条到顶部的垂直高度 :$(document).scrollTop();scroll

 

获取滚动条到左边的垂直宽度 :$(document).scrollLeft();方法



计算元素位置和偏移量:$(id).offset();margin


offset方法是一个颇有用的方法,它返回包装集中第一个元素的偏移信息。默认状况下是相对body的偏移信息。结果包含 top和left两个属性。

top

offset(options, results)di

 

options.relativeTo  指定相对计滚动条

 

算偏移位置的祖先元素。这个元素应该是relative或absolute定位。省略则相对body。

 

options.scroll  是否把

 

滚动条计算在内,默认TRUE

 

options.padding  是否把padding计算在内,默认false

 

options.margin      是否把margin计算在内,默认true

 

options.border  是否把边框计算在内,默认true

子页面控制父页面:

parent.document.documentElement.scrollTop;

 

parent.document.documentElement.clientHeight;

相关文章
相关标签/搜索