在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 |
作者:匿名用户404
链接:https://www.jianshu.com/p/fc5a4a3bccba
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2819/viewspace-2805277/ ,如需转载,请注明出处,否则将追究法律责任。