jquery outerHeight方法 outerWidth方法

outerWidth(options)
获取第一个匹配元素外部宽度(默认包括补白和边框)。
此方法对可见和隐藏元素均有效。
返回值:Integer
参数:
options(Boolean) : (false) 设置为 true 时,计算边距在内。
示例:
获取第一段落外部宽度。
HTML 代码:
<div>
<div id="test" style="width:80px;margin:10px;"></div>
</div>
jQuery 代码:
var w = $("#test").outerWidth(true);
$("#test").html(w);
结果:
<div>
<div id="test" style="width:80px;margin:10px;">100</div>
</div>

outerHeight(options)

获取第一个匹配元素外部高度(默认包括补白和边框)。
此方法对可见和隐藏元素均有效。
返回值:Integer
参数:
options(Boolean) : (false) 设置为 true 时,计算边距在内。
示例:
获取第一段落外部高度。
HTML 代码:
<div>
<div id="test" style="height:20px;margin:10px;"></div>
</div>
jQuery 代码:
var h = $("#test").outerHeight(true);
$("#test").html(h);
结果:
<div>
<div id="test" style="height:20px;margin:10px;">40</div>
</div>
</div>

posted @ 2012-11-07 13:40  zhjahch  阅读(9573)  评论(0编辑  收藏  举报