jQuery獲取或設定元素的寬度和高度
ofollow,noindex" target="_blank">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() 方法設定或返回元素的高度(包括內邊距和邊框)。
posted @2018-11-29 15:45 曹慶軍 閱讀(... ) 評論(... )編輯