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>