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