English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
outerWidth() method to get or set the external width of the selected element (including padding, border).
outerWidth(truemethod to get or set the external width of the selected element (including padding, border and margin).
When using the externalWidth() methodGetWhen setting the width, it will returnThe first selected elementWidth.
When using the externalWidth() methodSetWhen setting the width, it will setAll selected elementsWidth.
As shown in the figure below, the externalWidth() method includes padding and borders:
To include margins, use outerWidth(true).
Get the external width:
$(selector).outerWidth()
Get the external width including margins:
$(selector).outerWidth(true)
Set the external width:
$(selector).outerWidth(value)
Get the external width of the DIV element:
$("div").click(function(){ $(this).outerWidth(); });Teste e veja‹/›
Get the external width of the DIV element (including margins):
$("div").click(function(){ $(this).outerWidth(true); });Teste e veja‹/›
Set the external width of all paragraphs:
$("button").click(function(){ $("p").outerWidth("}}100); });Teste e veja‹/›
Configure the external width of all paragraphs using different unit settings:
$("#btn1").click(function(){ $("p").outerWidth("}}100); }); $("#btn2").click(function(){ $("p").outerWidth("10em"); }); $("#btn3").click(function(){ $("p").outerWidth("100vw"); });Teste e veja‹/›
Exibir a diferença entre width(), height(), innerHeight(), innerWidth(), outerWidth() e outerHeight():
$("button").click(function(){ $("div").width(); $("div").innerWidth(); $("div").outerWidth(); $("div").height(); $("div").innerHeight(); $("div").outerHeight(); });Teste e veja‹/›
Parâmetro | Descrição |
---|---|
value | Número inteiro que representa pixels, ou número inteiro com unidade opcional adicional (como string) |