在jQuery中,獲取元素高度的函數(shù)有3個(gè),它們分別是height()、innerHeight()、outerHeight()
與此相對應(yīng)的是,獲取元素寬度的函數(shù)也有3個(gè),它們分別是width()、innerWidth()、outerWidth()
下面我以height()、innerHeight()、outerHeight()三個(gè)函數(shù)為例,以元素element的盒模型為例來介紹它們之間的區(qū)別。

Paste_Image.png
| 函數(shù) | 高度范圍 | |
|---|---|---|
| height() | content | |
| innerHeight() | content+padding | |
| outerHeight() | content+padding+border | |
| outerHeight(true) | content+padding+border+margin |