首页 > 语言 > JavaScript > 正文

Jquery 的outerHeight方法使用介绍

2024-05-06 15:51:50
字体:
来源:转载
供稿:网友
获取第一个匹配元素外部高度默认包括补白和边框,在本文将为大家介绍下具体的实现代码,此方法对可见和隐藏元素均有效,感兴趣的朋友可以了解下

获取第一个匹配元素外部高度(默认包括补白和边框)。

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

outerHeight(options)

optionsBoolean默认值:'false'

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

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

HTML 代码:

复制代码 代码如下:


<p>Hello</p><p>2nd Paragraph</p>


jQuery 代码:

复制代码 代码如下:


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


结果:

复制代码 代码如下:


<p>Hello</p><p>outerHeight: 35 , outerHeight(true):55</p>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选