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;

相關文章
相關標籤/搜索