欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

jQuery获取或设置元素的宽度和高度

程序员文章站 2022-05-03 13:06:26
jQuery获取或设置元素的宽度和高度: 可使用以下3种方法: 1,jQuery width() 和 height() 方法; 2,innerWidth() 和 innerHeight() 方法; 3,outerWidth() 和 outerHeight()方法。 jQuery width() 和 ......
jquery获取或设置元素的宽度和高度:
可使用以下3种方法:
1,jquery width() 和 height() 方法;
2,innerwidth() 和 innerheight() 方法;
3,outerwidth() 和 outerheight()方法。
 
jquery width() 和 height() 方法,innerwidth() 和 innerheight() 方法,outerwidth() 和 outerheight() 方法的区别如下:
一、jquery width() 和 height() 方法
width() 方法设置或返回元素的宽度(不包括内边距、边框或外边距)。
height() 方法设置或返回元素的高度(不包括内边距、边框或外边距)。
 
二、jquery innerwidth() 和 innerheight() 方法
innerwidth() 方法设置或返回元素的宽度(包括内边距)。
innerheight() 方法设置或返回元素的高度(包括内边距)。
 
三、jquery outerwidth() 和 outerheight() 方法
outerwidth() 方法设置或返回元素的宽度(包括内边距和边框)。
outerheight() 方法设置或返回元素的高度(包括内边距和边框)。