outsideHeight()方法獲取或設置所選元素的外部高度(包括padding,border)。
outsideHeight(true)方法獲取或設置所選元素的外部高度(包括padding,border和margin)。
當使用externalHeight()方法獲取高度時,它將返回第一個選定元素的高度。
當使用externalHeight()方法設置高度時,它將設置所有選定元素的高度。
如下圖所示,externalHeight()方法包括padding和border:
要包括margin,請使用outerHeight(true)。

獲取外部高度:
$(selector).outerHeight()
獲取包括邊距在內(nèi)的外部高度:
$(selector).outerHeight(true)
設置外部高度:
$(selector).outerHeight(value)
獲取DIV元素的外部高度:
$("div").click(function(){
$(this).outerHeight();
});測試看看?/?獲取DIV元素的外部高度(包括邊距):
$("div").click(function(){
$(this).outerHeight(true);
});測試看看?/?設置所有段落的外部高度:
$("button").click(function(){
$("p").outerHeight(100);
});測試看看?/?使用不同的單位設置所有段落的外部高度:
$("#btn1").click(function(){
$("p").outerHeight(100);
});
$("#btn2").click(function(){
$("p").outerHeight("7em");
});
$("#btn3").click(function(){
$("p").outerHeight("100vh");
});測試看看?/?顯示width(),height(),innerHeight(),innerWidth(),outerWidth()和outerHeight()之間的差異:
$("button").click(function(){
$("div").width();
$("div").innerWidth();
$("div").outerWidth();
$("div").height();
$("div").innerHeight();
$("div").outerHeight();
});測試看看?/?| 參數(shù) | 描述 |
|---|---|
| value | 表示像素數(shù)的整數(shù),或附加了可選度量單位的整數(shù)(作為字符串) |