JSLite - 尺寸位置
如有疑問歡迎到這些地方交流,歡迎加入JSLite.io組織團體共同開發!
offset
取得目前元素相對於document的位置。回傳一個物件含有:left|top|width|height
$("#box").offset() //⇒Object {left: 8, top: 8, width: 1260, height: 0} $("#box").offset().left //⇒ 8
width
width() ⇒ number
width(value) ⇒ self
width (function(index, oldWidth){ ... }) ⇒ self
取得物件象集合中第一個元素的寬,或設定物件集合所有元素的寬。
$("#box").width() // => 342 $(window).width() // => 456 (可视区域宽度) $(document).width() // => dsf
height
height() ⇒ number
height(value) ⇒ self
height(function(index, oldWidth){ ... } ) ⇒ self
取得物件象集合中第一個元素的高,或設定物件集合所有元素的高。
$("#box").height() // => 342 $(window).height() // => 456 (可视区域高度) $(document).height() // => dsf
scrollLeft
scrollLeft() ⇒ self 取得符合的元素集合中第一個元素的目前水平捲軸的位置
$("body").scrollLeft(400);
scrollTop
scrollTop() ⇒ self 取得符合的元素集合中第一個元素的目前垂直捲軸的位置
$("body").scrollTop(400);