jquery中innerheight outerHeight()与height()的区别

Posted 模糊的星空

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquery中innerheight outerHeight()与height()的区别相关的知识,希望对你有一定的参考价值。

1. .height()

获取匹配元素集合中的第一个元素的当前计算高度值 或 设置每一个匹配元素的高度值(带一个参数)。

技术分享

 

注意:1).css(‘height‘)和.height()之间的区别是后者返回一个没有单位的数值(例如,400),前者是返回带有完整单位的字符串(例如,400px)。

2).height()总是返回内容宽度,不管CSSbox-sizing属性值。.height(‘value‘)设置的容器宽度是根据CSSbox-sizing属性来定的, 将这个属性值改成border-box,将造成这个函数改变这个容器的outerHeight,而不是原来的内容高度。

2. .innerHeight()

为匹配的元素集合中获取第一个元素的当前计算高度值,包括padding,但是不包括border。

技术分享

 

3. .outerHeight()

获取元素集合中第一个元素的当前计算高度值,包括padding,border和选择性的margin。返回一个整数(不包含“px”)表示的值 ,或如果在一个空集合上调用该方法,则会返回 null。

技术分享

 

在.outerHeight()计算中总是包含padding-top ,padding-bottom 和 border-top,border-bottom ;如果includeMargin参数是true,那么margin (top 和 bottom)也会被包含。

以上是关于jquery中innerheight outerHeight()与height()的区别的主要内容,如果未能解决你的问题,请参考以下文章

jquery中innerheight outerHeight()与height()的区别

jquery的innerHeight()和outerHeight()的区别

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

通过jQuery获取容器尺寸的方法height()innerHeight()outerHeight()的区别总结

jQuery 的 width()height()innerWidth()innerHeight()outWidth()outHeight() 的区别

jquery 对象的 heightinnerHeightouterHeight 的区别以及DOM 元素的 clientHeightoffsetHeightscrollHeightoffset(代码片段