在jQuery中,獲取元素高度的函數有3個,它們分別是height()、innerHeight()、outerHeight()
與此相對應的是,獲取元素寬度的函數也有3個,它們分別是width()、innerWidth()、outerWidth()
下面我以height()、innerHeight()、outerHeight()
三個函數為例,以元素element的盒模型為例來介紹它們之間的區別。
Paste_Image.png
函數 | 高度范圍 | |
---|---|---|
height() | content | |
innerHeight() | content+padding | |
outerHeight() | content+padding+border | |
outerHeight(true) | content+padding+border+margin |