盒子尺寸(重点)
width()//这里获得的宽高跟css()数据类型不一样==内容的宽度
innerWidth()=width()+padding
outerWidth()=innerwidth()+border
outerWidth(true)==outerwidth +margin
height()
innerHeight()
outerHeight()
outerHeight(true)
///这八个方法有的不能设置(没有setter方法),根据实际情况来:比如width(100)
盒子位置(重点)
offset()// 获取或设置坐标值(相对文档)设置值后变成相对定位,返回一个坐标对象,设置也传对象属性是left和top //offset().top offset({left:100})
position() // 获取坐标值(相对父亲)只能读取不能设置//readOnly
scrollTop()//设置或获取元素滚动条垂直卷去的距离:设置scrollTop(100)
scrollLeft()//设置或获取元素滚动条水平卷去的距离
<
script
>
var
div1 = $(
"#width1");
var
div2 = $(
"#width2");
//offset
//相对于文档 可以设置
var
setter1 =
div1.offset({
left:
200,
top:
200});
console.
log(
setter1);
//返回的是jq对象
//position
//相对于父亲 //只能读取不能设置
var
position1 =
div1.
position();
console.
log(
position1);
//scrolltop
div1[
0].
onwheel =
function () {
var
total =
0;
for(
i in
div1.
children()){
totao+=$(
div1.
children()[
i]).
height;
}
}
</
script
>