前端开发

 首页 > 前端开发 > jquery教程 > 区别jQuery中height与width

区别jQuery中height与width

分享到:
【字体:
导读:
          query中有三个获取element高度的方法,分别是:height(),innerHeight(),outerHeght(bool);同样对应的有三个获取element宽度的方法:width(),innerHeight(),outerHeight(bool),这三个方法分别对应怎样的元素属性,...

query中有三个获取element高度的方法,分别是:height(),innerHeight(),outerHeght(bool);同样对应的有三个获取element宽度的方法:width(),innerHeight(),outerHeight(bool),这三个方法分别对应怎样的元素属性,如下图所示:

从上面的图可以了解到:height()方法对应顶部style设置的width属性;

innerHeight()对应width+padding-top+padding-bottom;

outerHeight()对应width+padding-top+padding-bottom+border-top+border-bottom;

另外看到下面outerHeight与outerWidth的值不一样是由于outerWidth(bool)方法参数被设置成true,
这时会加上margin-top和margin-bottom;
即:outerWidth = width+padding-top+padding-bottom+border-top+border-bottom+margin-top+margin-bottom;

来个简单的示例吧





$(document).ready(function(){
 $("button").click(function(){
 $("#id200").width("300px");
 });
});



HELLO
W3SCHOOL
请点击这里

以上所述就是本文的全部内容了,希望大家能够喜欢。

分享到:
jquery ajax get success not called; aj...
管理后台不知道为啥出了点小bug,以前管用的一个功能突然不能用了,看了下数据接口是调用成功了,大周末的,又不好麻烦FE,只好自己看看了。   通过查看源代码发现,使用了jquery里的ajax方法,通过get回来的结果并没有按预期的执行success回调。   $.ajax({     url: '/antispammanage/fi...
jQuery中$this和$(this)的区别介绍
jQuery中$this和$(this)的区别介绍 // this其实是一个Html 元素。 // $this 只是个变量名,加$是为说明其是个jquery对象。 // 而$(this)是个转换,将this表示的dom对象转为jquery对象,这样就可以使用jquery提供的方法操作。     (function($){     $.fn.hilight = function(options){        ...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……