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


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() 方法设置或返回元素的高度(包括内边距和边框)。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM