jquery中innerWidth(),outerWidth(),outerWidth(true)和width()的区别
jquery中innerWidth(),outerWidth(),outerWidth(true)和width()的区别
var a = 元素本身的宽度;
width() = a;
innerWidth() = a+padding;
outerWidth() = a+padding+border;
outerWidth(true) = a+padding+border+margin;
在jQuery中,
width()方法用于获得元素宽度;
innerWidth()方法用于获得包括内边界(padding)的元素宽度,
outerWidth()方法用于获得包括内边界(padding)和边框(border)的元素宽度,
如果outerWidth()方法的参数为true则外边界(margin)也会被包括进来,即获得包括外边框(margin)、内边界(padding)和边框(border)的元素宽度。
同理,innerHeight方法与outerHeight方法也是用同样的方法计算相应的高度。
所以说:对于同一个元素应该是:
width()<=innerWidth()<=outerWidth()<=outerWidth(true); 举个例子:
<script type="text/javascript">
$(document).ready(function(){
$(".btn1").click(function(){
var obj=$("#p_obj");
alert(obj.width());
alert(obj.innerWidth());
alert(obj.outerWidth());
alert(obj.outerWidth(true));
});
});
</script>
<p id="p_obj" style=" width:200px; padding:10px; border:10px solid blue; margin:10px;">This is a paragraph.</p>
<button class="btn1">输出高度</button> 输出的结果分别是 200px, 220px, 240px, 260px.
jquery中innerWidth(),outerWidth(),outerWidth(true)和width()的区别的更多相关文章
- [转]jquery中innerWidth(),outerWidth(),outerWidth(true)和width()的区别
转自:http://www.cnblogs.com/keyi/p/5933981.html jquery中innerWidth(),outerWidth(),outerWidth(true)和wi ...
- jquery中innerwidth,outerwidth,outerwidth和width的区别
在jQuery中,width()方法用于获得元素宽度: innerWidth()方法用于获得包括内边界(padding)的元素宽度, outerWidth()方法用于获得包括内边界(padding)和 ...
- jQuery中detach&&remove&&empty三种方法的区别
jQuery中empty&&remove&&detach三种方法的区别 empty():移除指定元素内部的所有内容,但不包括它本身 remove():移除指定元素内部的 ...
- [转载]jQuery中wrap、wrapAll和wrapInner用法以及区别
原文地址:jQuery中wrap.wrapAll和wrapInner用法以及区别作者:伊少君 原文: <ul> <li title='苹果'>苹果</li> ...
- jQuery中的.bind()、.live()和.delegate()之间区别分析
jQuery中的.bind()..live()和.delegate()之间区别分析,学习jquery的朋友可以参考下. DOM树 首先,可视化一个HMTL文档的DOM树是很有帮助的.一个简单的 ...
- jQuery中的height()、innerheight()、outerheight()的区别总结
在前端jQuery代码中突然看到outerheight(),第一感觉就是,这是什么鬼?然后仔细查阅了一下,居然发现还有这么多相似的东西. 在jQuery中,获取元素高度的函数有3个,它们分别是heig ...
- jQuery中attr()、prop()、data()用法及区别
.attr(),此方法从jq1.0开始一直存在,官方文档写的作用是读/写DOM的attribute值,其实1.6之前有时候是attribute,有时候又是property..prop(),此方法jq1 ...
- jquery中的$("#id")与document.getElementById("id")的区别
以前一直认为jquery中的$("#id")和document.getElementByIdx_x("id")得到的效果是一样的,今天做特效的时候才发现并不是这 ...
- jquery 中的 $("#id") 与 document.getElementById("id") 的区别
以前没注意过,认为jquery 中的 $("#air") 与 document.getElementById("air") 是一回事,指的是同一个东西.在今天写 ...
随机推荐
- VCSA 6.5 升级 VCSA 6.7
VCSA 6.7已于4月17日正式发布,文件名为VMware-VCSA-all-6.7.0-8217866.iso,国内百度网盘已有下载链接,请自行搜索. 下载后解压,运行\VMware-VCSA-a ...
- leetcode925
public class Solution { public bool IsLongPressedName(string name, string typed) { var list1 = new L ...
- eclipse怎么导入maven项目 eclipse导入maven项目详细教程
转自:http://www.pc6.com/infoview/Article_114542.html Eclipse怎么导入maven项目一直是困扰着大量程序猿和刚上手小白们的问题,使用eclipse ...
- J2SE 8的Lambda --- functions
functions //1. Runnable 输入参数:无 返回类型void new Thread(() -> System.out.println("In Java8!" ...
- 使用SendMessage进行进程间通信
Imports System.Runtime.InteropServices Public Class Monitor <DllImport("user32.dll", Ch ...
- 使用Ping来做等待的时间计算
利用ping两次发送消息之间的间隔时间.ping在发送多个消息时,在得到上一次消息的回应后,它会再等待1秒的时间才发送下一次消息,而这个回应时间因机型.系统和网络配置而不同,其中IP地址尤其关键,只有 ...
- Spring boot profile 多环境配置
1.多Profile文件 我们在主配置文件编写的时候,文件名可以是 application-{profile}.properties/yml 默认使用application.properties的配置 ...
- spring coud feign
1. 依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>sprin ...
- Java中的默认构造函数
java中如果在一个类中没有写明任何构造函数的,那么会存在一个无参的构造函数,如下: public class Children { private String name; private Stri ...
- Required String parameter ' ' is not present
Required String parameter ' ' is not present 报错原因: url中的参数错误. 解决方法: 1.修正url中的参数的值. 2.在Controller层中的@ ...