码迷,mamicode.com
首页 > Web开发 > 详细

jQuery height()、innerHeight()、outerHeight()函数的区别详解

时间:2017-04-14 00:14:02      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:win   src   tab   png   htm   query   介绍   document   http   

jQuery height()、innerHeight()、outerHeight()函数的区别详解

在jQuery中,获取元素高度的函数有3个,它们分别是height()、 innerHeight()outerHeight()

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

在这里,我们以height()innerHeight()outerHeight()3个函数为例,来详细介绍它们之间的区别。

下面我们以元素element的盒模型为例来介绍它们之间的区别。

技术分享

函数高度范围jQuery版本支持写操作
height() height 1.0+
1.0+
innerHeight() height + padding 1.2.6+ 1.8.0+
outerHeight() height + padding + border 1.2.6+
outerHeight(true) height+padding+border+margin 1.2.6+
1、 只有height()函数可用于windowdocument对象。
2、 "支持写操作"表示该函数可以为元素设置高度值。
3、 1.4.1+ height()新增支持参数为函数(之前只支持数值)。
4、 1.8.0+ innerHeight()支持参数为数值或函数。

jQuery height()、innerHeight()、outerHeight()函数的区别详解

标签:win   src   tab   png   htm   query   介绍   document   http   

原文地址:http://www.cnblogs.com/linjing-blog/p/6706847.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!