zl程序教程

您现在的位置是:首页 >  前端

当前栏目

Jquery的outerHeight方法使用介绍

jQuery方法 使用 介绍
2023-06-13 09:15:05 时间
获取第一个匹配元素外部高度(默认包括补白和边框)。

此方法对可见和隐藏元素均有效。

outerHeight(options)

optionsBoolean默认值:"false"

设置为true时,计算边距在内。

描述:
获取第一段落外部高度。

HTML代码:
复制代码代码如下:

<p>Hello</p><p>2ndParagraph</p>

jQuery代码:
复制代码代码如下:

varp=$("p:first");
$("p:last").text("outerHeight:"+p.outerHeight()+",outerHeight(true):"+p.outerHeight(true));

结果:
复制代码代码如下:
<p>Hello</p><p>outerHeight:35,outerHeight(true):55</p>