jQuery中的height innerHeight outerHeight区别示例介绍_jquery

标准浏览器下:

height:高度

innerHeight:高度+补白
outerHeight:高度+补白+边框,参数为true时:高度+补白+边框+边距

html代码:

复制代码 代码如下:

<div class="width: 150px;height:20px;float: left;border: 2px solid red;margin: 10px;margin: 10px;padding: 10px;" id="test">jjjjj</div>

js代码:

复制代码 代码如下:

alert($("#test").height());
alert($("#test").innerHeight());
alert($("#test").outerHeight());
alert($("#test").outerHeight(true));

结果:
在ie中的结果:17px,37px,41px,61px
在ff中的结果:20px,40px,44px,64px

html代码:

复制代码 代码如下:

<div class="width: 150px;height: 41px;float: left;border: 2px solid red;margin: 10px;margin: 10px;padding: 10px;" id="test">jjjjj</div>

js代码:

复制代码 代码如下:

alert($("#test").height());
alert($("#test").innerHeight());
alert($("#test").outerHeight());
alert($("#test").outerHeight(true));
[html]
结果:
在ie中的结果:17px,37px,41px,61px
在ff中的结果:41px,61px,65px,85px

html代码:
[code]
<div class="width: 150px;height: 42px;float: left;border: 2px solid red;margin: 10px;margin: 10px;padding: 10px;" id="test">jjjjj</div>

js代码:

复制代码 代码如下:

alert($("#test").height());
alert($("#test").innerHeight());
alert($("#test").outerHeight());
alert($("#test").outerHeight(true));

结果:
在ie中的结果:18px,38px,42px,62px
在ff中的结果:42px,62px,66px,86px

html代码:

复制代码 代码如下:

<div class="width: 150px;height: 60px;float: left;border: 2px solid red;margin: 10px;margin: 10px;padding: 10px;" id="test">jjjjj</div>

js代码:

复制代码 代码如下:

alert($("#test").height());
alert($("#test").innerHeight());
alert($("#test").outerHeight());
alert($("#test").outerHeight(true));

结果:
在ie中的结果:36px,56px,60px,80px
在ff中的结果:60px,80px,84px,104px

结论:在ie中height包含border和padding并且height最小值为17px ,同理可得width,不过它最小值为15px

时间: 2024-09-20 00:20:25

jQuery中的height innerHeight outerHeight区别示例介绍_jquery的相关文章

JQuery与JS里submit()的区别示例介绍_jquery

ASP.NET 的服务器控件回发是使用这一段JS代码: 复制代码 代码如下: var theForm = document.forms['form1']; if (!theForm) { theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTAR

jQuery中serializeArray()与serialize()的区别实例分析_jquery

本文实例讲述了jQuery中serializeArray()与serialize()的区别.分享给大家供大家参考,具体如下: serialize()序列化表单元素为字符串,用于 Ajax 请求. serializeArray()序列化表单元素为JSON数据. 具体实例如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xht

谈谈Jquery中的children find 的区别有哪些_jquery

精华:find方法能找子孙,children方法只能找儿子 一.Jquery中children 语法 .children(selector) 说明 expr是表达式,可选参数,所有选择器中的表达式都可以用在这,比如按标签名"div",按类名".class",按序号":first"等等,如果表达式为空,那么返回的是所有的孩子,返回的结果仍为jQuery对象.  二.Jquery中find find() 方法获得当前元素集合中每个元素的后代,通过选择

JQuery与JS里submit()的区别示例介绍

 这篇文章主要介绍了JQuery与JS里submit()的区别,需要的朋友可以参考下 ASP.NET 的服务器控件回发是使用这一段JS代码:   代码如下: var theForm = document.forms['form1'];  if (!theForm) {  theForm = document.form1;  }  function __doPostBack(eventTarget, eventArgument) {  if (!theForm.onsubmit || (theFo

javascript中interval与setTimeOut的区别示例介绍

 这篇文章主要介绍了javascript中interval与setTimeOut的区别,需要的朋友可以参考下 setTimeout(code,millisec) //- 在指定时间后执行代码    code必须:    millisec必须:    clearTimeout(setTimeoutId) //- 取消 setTimeout()    setInterval(code,millisec)://指定间隔毫秒内循环执行代码    code必须:    millisec必须:    cle

jQuery中对节点进行操作的相关介绍_jquery

动态创建Dom节点 jQuery中使用$(html字符串)来动态创建Dom节点,并且返回一个jQuery对象,可以调用append等方法将创建的节点添加到Dom中. 例如:         var link = $("<a href='http://www.baidu.com'>百度</a>");         $("div:first").append(link); 添加节点元素的方法: Append方法用来在元素的末尾追加元素(最后一个

JQuery中的html()、text()、val()区别示例介绍_jquery

1.HTML html():取得第一个匹配元素的html内容.这个函数不能用于XML文档.但可以用于XHTML文档 html(val):设置每一个匹配元素的html内容.这个函数不能用于XML文档.但可以用于XHTML文档. 2.TEXT text():取得所有匹配元素的内容. 结果是由所有匹配元素包含的文本内容组合起来的文本.这个方法对HTML和XML文档都有效. text(val):设置所有匹配元素的文本内容 与 html() 类似, 但将编码 HTML (将 "<" 和 &

jQuery中delegate与on的用法与区别示例介绍_jquery

在jQuery1.7中 .delegate()已被.on()取代.对于早期版本,它仍然使用事件委托的最有效手段. 在事件绑定和委派,delegate()和on在一般情况下,这两种方法是等效的. .delegate() 指定的元素(属于被选元素的子元素)添加一个或多个事件处理程序,并规定当这些事件发生时运行的函数. 复制代码 代码如下: // jQuery 1.4.3+ $( elements ).delegate( selector, events, data, handler ); // jQ

jQuery学习之prop和attr的区别示例介绍_jquery

1..prop( propertyName ) 获取匹配集合中第一个元素的Property的值 2. .prop( propertyName, value ) .prop( map ) .prop( propertyName, function(index, oldPropertyValue) ) 给匹配元素集合设定一个或多个属性 .prop()和 .attr()区别 下面是关于jQuery1.6和1.6.1中Attributes模块变化的描述,以及.attr()方法和.prop()方法的首选使