.innerWidth()
methodThe .innerWidth()
method in jQuery is used to get/set the inner width (including padding but not border) of the matched element.
.innerWidth()
method Syntax.innerWidth() .innerWidth(value) .innerWidth(function)
Parameter | Type | Description |
---|---|---|
value |
String,Number | the width value to set |
funtion(index, oldWidth) |
Function | a function returning the inner width to set. index is the position of the element in the set.(based on 0) oldWidth is the old inner width. |
.innerWidth()
Get the current computed inner width(including padding but not border) of the first matched element.(If the element is not visible, the width would be 0 )
Get the inner width of the first paragraph
$("p").innerWidth();
.innerWidth(value)
Set the inner width(including padding but not border) of every matched elements.
Set the innerWidth of each p to 300px
$("p").innerWidth(300);
.innerWidth(function)
Set the innerWidth of the element to 20px wider than the previous.
$("p").innerWidth(function(index,oldValue){ return 20*index + oldValue; });