jQuery帮助之CSS尺寸(五)outerHeight、outerWidth
2009-11-14 00:14
344 查看
以便更好控制元素来满足我们的要求,那么我们可以通过outerHeight(options)和outerWidth(options)来获取到这部分的高度和宽度。
outerHeight(options)
获取第一个匹配元素外部高度(默认包括补白和边框)。
此方法对可见和隐藏元素均有效。
返回值:Integer
参数:
options(Boolean) : (false) 设置为 true 时,计算边距在内。
示例:
获取第一段落外部高度。
HTML 代码:
<p>Hello</p><p>2nd Paragraph</p>
jQuery 代码:
var p = $("p:first");
$("p:last").text( "outerHeight:" + p.outerHeight() + " , outerHeight(true):" + p.outerHeight(true) );
结果:
<p>Hello</p><p>outerHeight: 35 , outerHeight(true):55</p>
outerWidth(options)
获取第一个匹配元素外部宽度(默认包括补白和边框)。
此方法对可见和隐藏元素均有效。
返回值:Integer
参数:
options(Boolean) : (false) 设置为 true 时,计算边距在内。
示例:
获取第一段落外部宽度。
HTML 代码:
<p>Hello</p><p>2nd Paragraph</p>
jQuery 代码:
var p = $("p:first");
$("p:last").text( "outerWidth:" + p.outerWidth() + " , outerWidth(true):" + p.outerWidth(true) );
结果:
<p>Hello</p><p>outerWidth: 65 , outerWidth(true):85</p>
outerHeight(options)
获取第一个匹配元素外部高度(默认包括补白和边框)。
此方法对可见和隐藏元素均有效。
返回值:Integer
参数:
options(Boolean) : (false) 设置为 true 时,计算边距在内。
示例:
获取第一段落外部高度。
HTML 代码:
<p>Hello</p><p>2nd Paragraph</p>
jQuery 代码:
var p = $("p:first");
$("p:last").text( "outerHeight:" + p.outerHeight() + " , outerHeight(true):" + p.outerHeight(true) );
结果:
<p>Hello</p><p>outerHeight: 35 , outerHeight(true):55</p>
outerWidth(options)
获取第一个匹配元素外部宽度(默认包括补白和边框)。
此方法对可见和隐藏元素均有效。
返回值:Integer
参数:
options(Boolean) : (false) 设置为 true 时,计算边距在内。
示例:
获取第一段落外部宽度。
HTML 代码:
<p>Hello</p><p>2nd Paragraph</p>
jQuery 代码:
var p = $("p:first");
$("p:last").text( "outerWidth:" + p.outerWidth() + " , outerWidth(true):" + p.outerWidth(true) );
结果:
<p>Hello</p><p>outerWidth: 65 , outerWidth(true):85</p>
您可能感兴趣的文章:
相关文章推荐
- jQuery帮助之CSS尺寸(五)outerHeight、outerWidth
- jQuery帮助之CSS尺寸(五)outerHeight、outerWidth
- jquery中的尺寸函数width(),height(),innerWidth(),outerWidth()等的用法
- jquery outerHeight方法 outerWidth方法 获取元素实际宽度高度
- jQuery - 尺寸width() height() innerWidth() innerHeight() outerWidth() outerHeight()(二十一)
- jquery outerHeight方法 outerWidth方法
- jquery outerHeight方法 outerWidth方法 获取元素实际宽度高度
- jquery outerHeight方法 outerWidth方法
- jquery outerHeight方法 outerWidth方法
- jQuery 提供多个处理尺寸的重要方法:width() height() innerWidth() innerHeight() outerWidth() outerHeight()
- jquery基础教程四(css的操作之css,height和width)
- JQUERY操作css与css()方法、获取设置尺寸;
- jQuery位置、CSS和尺寸
- JQuery详细教程三之HTML(css() 与尺寸)
- jquery outerHeight方法 outerWidth方法
- Jquery 的outerHeight和outerHeightWidth
- [软件推荐]jQuery,JavaScript,HTML,CSS,PHP,MySQL,正则表达式 CHM帮助手册
- jquery中innerheight outerHeight()与height()的区别
- [jQuery教程]jquery基础教程四(css的操作之css,height和width)
- jquery中outerWidth和css中的box-sizing