jQuery outerHeight() 方法
定義和用法
outerHeight() 方法返回第一個匹配元素的外層高度。
如下圖所示,此方法包括內邊距(padding)和邊框(border)。
提示:要包含外邊距(margin),請使用 outerHeight(true)。
相關方法
- width() - 設定或返回元素的 CSS 寬度
- height() - 設定或返回元素的高度
- innerWidth() - 返回元素的 CSS 寬度(包括內邊距)
- innerHeight() - 返回元素的 CSS 高度(包括內邊距)
- outerWidth() - 返回元素的寬度(包括內邊距和邊框)。
語法
$(選擇器).outerHeight(includeMargin)
引數 | 描述 |
---|---|
includeMargin | 可選。一個布林值,指定是否包含外邊距
|
親手嘗試 - 示例
包含外邊距
指定是否包含外邊距。
使用相關方法顯示尺寸
如何使用 width()、height()、innerHeight()、innerWidth()、outerWidth() 和 outerHeight()。