如有疑問(wèn)歡迎到這些地方交流,歡迎加入JSLite.io組織團(tuán)伙共同開(kāi)發(fā)!
segmentfault社區(qū) | 官方網(wǎng)站 | 官方文檔-更詳細(xì) | Issues
獲得當(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() ? 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() ? number
height(value) ? self
height(function(index, oldWidth){ ... }) ? self
獲取對(duì)象象集合中第一個(gè)元素的高,或設(shè)置對(duì)象集合所有元素的高。
$("#box").height() // => 342
$(window).height() // => 456 (可視區(qū)域高度)
$(document).height() // => dsf
scrollLeft() ? self
獲取匹配的元素集合中第一個(gè)元素的當(dāng)前水平滾動(dòng)條的位置
$("body").scrollLeft(400);
scrollTop() ? self
獲取匹配的元素集合中第一個(gè)元素的當(dāng)前垂直滾動(dòng)條的位置
$("body").scrollTop(400);
更多建議: