jQuery帮助之CSS尺寸(五)outerHeight、outerWidth
作者:bea
以便更好控制元素来满足我们的要求,那么我们可以通过outerHeight(options)和outerWidth(options)来获取到这部分的高度和宽度。outerHeight(options) 获取第一个匹配元素外部高度(默认包括补白和边框)。 此方法对可见和隐藏元素均有效。 返回值:Integer 参数: options(Boolean) : (false) 设置为 true 时,计算边距在内。 示例: 获取第一段落外部高度。 HTML 代码: <p>He
以便更好控制元素来满足我们的要求,那么我们可以通过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>
有用 |
无用
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>
猜你喜欢
您可能感兴趣的文章:
- 页面版文本框智能提示JS代码
- js url传值中文乱码之解决之道
- js trim函数 去空格函数与正则集锦
- div移动 输入框不能输入的问题
- ExtJS Window 最小化的一种方法
- JS获取dom 对象 ajax操作 读写cookie函数
- jquery中的$(document).ready()与window.onload的区别
- jQuery html()等方法介绍
- JQuery toggle使用分析
- JavaScript 读取图片实例代码
- javascript 随机抽奖程序代码
- javascript 图片放大效果函数
- JavaScript OOP类与继承
- JavaScript的eval JSON object问题
- Javascript 中文字符串处理额外注意事项
- Dojo 学习笔记入门篇 First Dojo Example
- flash 得到自身url参数的代码
- javascript 去字符串空格终极版(支持utf8)
- jQuery checkbox全选/取消全选实现代码