手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jQuery帮助之CSS尺寸(五)outerHeight、outerWidth
jQuery帮助之CSS尺寸(五)outerHeight、outerWidth
摘要:以便更好控制元素来满足我们的要求,那么我们可以通过outerHeight(options)和outerWidth(options)来获取到这...

以便更好控制元素来满足我们的要求,那么我们可以通过outerHeight(options)和outerWidth(options)来获取到这部分的高度和宽度。

outerHeight(options)

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

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

返回值:Integer

参数:

options(Boolean) : (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>

outerWidth(options)

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

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

返回值:Integer

参数:

options(Boolean) : (false) 设置为 true 时,计算边距在内。

示例:

获取第一段落外部宽度。

HTML 代码:

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

jQuery 代码:

var p = $("p:first");

$("p:last").text( "outerWidth:" + p.outerWidth() + " , outerWidth(true):" + p.outerWidth(true) );

结果:

<p>Hello</p><p>outerWidth: 65 , outerWidth(true):85</p>

【jQuery帮助之CSS尺寸(五)outerHeight、outerWidth】相关文章:

js-穷举法 (y0h)

Javascript中的Prototype到底是什么

多个iframe自动调整大小的问题

gameboy网页闯关游戏(riddle webgame)--仿微信聊天的前端页面设计和难点

Eclipse编辑jsp、js文件时卡死现象的解决办法汇总

jquery合并表格中相同文本的相邻单元格

jquery任意位置浮动固定层插件用法实例

浏览器检测JS代码(兼容目前各大主流浏览器)

JavaScript中使用自然对数ln的方法

提高代码性能技巧谈—以创建千行表格为例

精品推荐
分类导航