-
Notifications
You must be signed in to change notification settings - Fork 265
/
Copy pathinnerWidth.xml
107 lines (106 loc) · 3.93 KB
/
innerWidth.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?xml version="1.0"?>
<entries>
<desc>Get the current computed inner width (including padding but not border) for the first element in the set of matched elements or set the inner width of every matched element.</desc>
<entry type="method" name="innerWidth" return="Number">
<title>.innerWidth()</title>
<signature>
<added>1.2.6</added>
</signature>
<desc>Get the current computed inner width for the first element in the set of matched elements, including padding but not border.</desc>
<longdesc>
<p>This method returns the width of the element, including left and right padding, in pixels. If called on an empty set of elements, returns <code>undefined</code> (<code>null</code> before jQuery 3.0).</p>
<p>This method is not applicable to <code>window</code> and <code>document</code> objects; for these, use <code><a href="/width/">.width()</a></code> instead.</p>
<figure>
<img src="/resources/0042_04_05.png"/>
<figcaption>Figure 1 - Illustration of the measured width</figcaption>
</figure>
</longdesc>
<note id="dimensions-number" type="additional" data-title=".innerWidth()"/>
<note id="hidden-element-dimensions" type="additional" data-title=".innerWidth()"/>
<example>
<desc>Get the innerWidth of a paragraph.</desc>
<code><![CDATA[
var p = $( "p" ).first();
$( "p" ).last().text( "innerWidth:" + p.innerWidth() );
]]></code>
<css><![CDATA[
p {
margin: 10px;
padding: 5px;
border: 2px solid #666;
}
]]></css>
<html><![CDATA[
<p>Hello</p>
<p></p>
]]></html>
</example>
<category slug="css"/>
<category slug="dimensions"/>
<category slug="manipulation/style-properties"/>
<category slug="version/1.2.6"/>
</entry>
<entry type="method" name="innerWidth" return="jQuery">
<signature>
<added>1.8</added>
<argument name="value">
<type name="String"/>
<type name="Number"/>
<desc>A number representing the number of pixels, or a number along with an optional unit of measure appended (as a string).</desc>
</argument>
</signature>
<signature>
<added>1.8</added>
<argument name="function" type="Function">
<argument name="index" type="Integer" />
<argument name="width" type="Number" />
<return>
<type name="String"/>
<type name="Number"/>
</return>
<desc>A function returning the inner width (including padding but not border) to set. Receives the index position of the element in the set and the old inner width as arguments. Within the function, <code>this</code> refers to the current element in the set.</desc>
</argument>
</signature>
<desc>Set the CSS inner width of each element in the set of matched elements.</desc>
<longdesc>
<p>When calling <code>.innerWidth("value")</code>, the value can be either a string (number and unit) or a number. If only a number is provided for the value, jQuery assumes a pixel unit. If a string is provided, however, any valid CSS measurement may be used for the width (such as <code>100px</code>, <code>50%</code>, or <code>auto</code>). Note that in modern browsers, the CSS width property does not include padding, border, or margin, unless the <code>box-sizing</code> CSS property is used.</p>
<p>If no explicit unit is specified (like "em" or "%") then "px" is assumed.</p>
</longdesc>
<example>
<desc>Change the inner width of each div the first time it is clicked (and change its color).</desc>
<code><![CDATA[
var modWidth = 60;
$( "div" ).one( "click", function() {
$( this ).innerWidth( modWidth ).addClass( "mod" );
modWidth -= 8;
});
]]></code>
<css><![CDATA[
div {
width: 60px;
padding: 10px;
height: 50px;
float: left;
margin: 5px;
background: red;
cursor: pointer;
}
.mod {
background: blue;
cursor: default;
}
]]></css>
<html><![CDATA[
<div>d</div>
<div>d</div>
<div>d</div>
<div>d</div>
<div>d</div>
]]></html>
</example>
<category slug="css"/>
<category slug="dimensions"/>
<category slug="manipulation/style-properties"/>
<category slug="version/1.8"/>
</entry>
</entries>