Skip to content

inner/outer height/width setters, closes gh-98 #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion entries/innerWidth.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?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="Integer">
<title>.innerWidth()</title>
<signature>
<added>1.2.6</added>
</signature>
<desc>Get the current computed width for the first element in the set of matched elements, including padding but not border.</desc>
<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.</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>
Expand Down Expand Up @@ -35,3 +37,62 @@ $( "p:last" ).text( "innerWidth:" + p.innerWidth() );
<category slug="manipulation/style-properties"/>
<category slug="version/1.2.6"/>
</entry>

<entry type="method" name="innerWidth" return="jQuery">
<signature>
<added>1.8.0</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.0</added>
<argument name="function(index, width)" type="Function">
<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>