- 相關(guān)推薦
jQuery中outerWidth的方法介紹
本文實(shí)例講述了jQuery中outerWidth()方法用法。分享給大家供大家參考。具體分析如下:
此方法獲取第一個(gè)匹配元素外部寬度。
默認情況下外部高度是寬度(width)、內補白(padding)和邊框(border)之和。
如果參數設置為true的話(huà),外補白(margin)尺寸也會(huì )算入外部寬度。
此方法對可見(jiàn)和隱藏元素均有效。
可以與outerHeight()方法結合學(xué)習。
語(yǔ)法結構:
復制代碼 代碼如下:$(selector).outerWidth(options)
參數列表:
參數 描述 options 定義是否把外補白(margin)計算在內:
一.fase,外補白不計算在內,默認值。
二.true,外補白計算在內。
實(shí)例代碼:
復制代碼 代碼如下:
div{
background-color:green;
height:100px;
width:200px;
padding:10px;
margin:10px;
border:5px solid red;
}
$(document).ready(function(){
$("button").click(function(){
$("div").text($("div").outerWidth(true))
})
})
此處顯outerWidth()數值
點(diǎn)擊查看div的outerWidth
點(diǎn)擊按鈕可以顯示div的元素外部寬度。
希望本文所述對大家的jQuery程序設計有所幫助。
【jQuery中outerWidth的方法介紹】相關(guān)文章:
jQuery中prev()方法用法07-16
關(guān)于jQuery實(shí)現高亮顯示的方法介紹08-20
asp.net+jquery Jsonp使用方法介紹08-23
關(guān)于jquery簡(jiǎn)單圖片切換顯示效果實(shí)現方法介紹10-01
jQuery中parent()和siblings()的問(wèn)題10-16
jQuery程序設計08-05
jquery提交按鈕的代碼07-28
手繪中的透視方法08-18