首頁  >  CSS  > outerWidth([options])

返回值:Integer outerWidth([options])

概述

獲取第一個匹配元素外部寬度(預設包括補白和邊框)。

此方法對可見和隱藏元素均有效。

參數

options Boolean 預設值:'false' V1.2.6

設定為 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>