height([val|fn])
width([val|fn])
innerHeight()
innerWidth()
outerHeight([options])
outerWidth([options])
height width 参数分别可以是 val fn
//设置或者获取元素的宽和高
//获取出来是没有像素单位的 px
console.log($(".block").height());
console.log($(".block").width());
//设置的值不带px 设置的样式为行内样式
$(".block").height(300);
$(".block").width(300);
fn 回调函数
//index 代表当前元素的索引 old 代表当前元素的值
$(".block").height(function (index,old){
console.log(index, old);
return 100;
});
不包括边框 包括补白之内的属性
innerHeight()
innerWidth()
console.log($(".block").innerWidth());
console.log($(".block").innerHeight());
包含边框 获取的是宽和高度的问题
outerHeight([options])
outerWidth([options])
console.log($(".block").outerWidth());
console.log($(".block").outerHeight());
//参数 options 设置为true 计算的时候包含边距
//根据合资模型去计算元素整体宽和高
console.log($(".block").outerHeight(true));
console.log($(".block").outerWidth(true));
jQuery尺寸问题
最新推荐文章于 2025-04-07 01:06:56 发布
3578

被折叠的 条评论
为什么被折叠?



