JSLite Online Manual
/ JSLite - 尺寸位置
JSLite - 尺寸位置
如有疑問歡迎到這些地方交流,歡迎加入JSLite.io組織團(tuán)伙共同開發(fā)!
offset
獲得當(dāng)前元素相對(duì)于document的位置。返回一個(gè)對(duì)象含有: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
獲取對(duì)象象集合中第一個(gè)元素的寬,或設(shè)置對(duì)象集合所有元素的寬。
$("#box").width() // => 342 $(window).width() // => 456 (可視區(qū)域?qū)挾? $(document).width() // => dsf
height
height() ? number
height(value) ? self
height(function(index, oldWidth){ ... }) ? self
獲取對(duì)象象集合中第一個(gè)元素的高,或設(shè)置對(duì)象集合所有元素的高。
$("#box").height() // => 342 $(window).height() // => 456 (可視區(qū)域高度) $(document).height() // => dsf
scrollLeft
scrollLeft() ? self 獲取匹配的元素集合中第一個(gè)元素的當(dāng)前水平滾動(dòng)條的位置
$("body").scrollLeft(400);
scrollTop
scrollTop() ? self 獲取匹配的元素集合中第一個(gè)元素的當(dāng)前垂直滾動(dòng)條的位置
$("body").scrollTop(400);