jQuery之height()、innerHeight()、outerHeight()函数

在jQuery中,获取元素高度的函数有3个,它们分别是height()、innerHeight()、outerHeight()
与此相对应的是,获取元素宽度的函数也有3个,它们分别是width()、innerWidth()、outerWidth()

下面我以height()、innerHeight()、outerHeight()三个函数为例,以元素element的盒模型为例来介绍它们之间的区别。
jQuery之height()、innerHeight()、outerHeight()函数_第1张图片
Paste_Image.png
函数 高度范围
height() content
innerHeight() content+padding
outerHeight() content+padding+border
outerHeight(true) content+padding+border+margin
只有height()函数可用于window或document对象。

你可能感兴趣的:(jQuery之height()、innerHeight()、outerHeight()函数)