let box =$(".box");// let w = box.width();// // let h = box.height(300);// let h = box.height(function(index,value){// if(index == 0){// return 400;// }// })// console.log(h);// console.log(w);// let w = box.innerWidth();// let h = box.innerHeight();// console.log(w);// let w = box.outerWidth();let h = box.outerHeight(true);
console.log(h);
05.元素的位置
/*
offset() 获取或者设置 元素 到文档最左边和上面的距离
当元素没有定位的时候 给元素设置了 offset() 那么会自动添加定位属性
position() 获取元素定位的left 和top值,只能获取不能设置
返回值:以对象的形式把值返回
scrollTop() 获取滚动条的垂直位置 和设置滚动条
如果这个元素不存在滚动条 设置没有效果
scrollLeft() 获取滚动条的水平位置 和设置滚动条
*/let box =$(".box div");// let w = box.offset();// box.offset({ left: 0, top: 20 });// console.log(w);// let res = box.position();// let res = box.scrollTop(100);// box.scrollLeft(100);// console.log(res);// let res = $(document).scrollTop(200);// console.log(res);// 给document绑定一个滚动事件$(document).scroll(function(){// 获取页面被卷去的高度let res =$(document).scrollTop();if(res >=2000){$(document).scrollTop(0);}});
let res=$(this)//res的值得到的是当前点击的jQuery集合let res=$(this).siblings()//res得到的是当前这个元素的所有兄弟元素jQuerylet res=$(this).siblings().end()//res得到的是当前点击的jQuery集合
end()叫做返回上一级的jQuery集合