- 元素相对于文档的偏移量
var pos = $('#small').offset();
var _left = pos.left;
var _top= pos.top;
-
获取元素相对于父级元素的偏移量 offsetLeft offsetTop
var l = $('#small').position().left;
var t = $('#small').position().top;
3. **获取滚动的距离**
var sT = $(window).scrollTop();//
var sL = $(window).scrollLeft();
4. **设置滚动距离**
$(window).scrollTop(100);
$(window).scrollLeft(200);
5. **获取元素的宽度和高度**
var w = $('#big').width();
var h = $('#big').height();
6. **设置宽度和高度**
$('#big').width(500);
$('#big').height(300);
7. **可视区域的宽度和高度**
var cW = $(window).width();
var cH = $(window).height();
8. **获取文档的宽度和高度**
var sH = $(document).height();
var sW = $(document).width();
网友评论