Skip to content

Commit 08bdef4

Browse files
gibson042kswedberg
authored andcommitted
.width() and .height(): synhronize documentation
* Include the style/script warning * Follow the style guide for comments * Ref jQuery #14545 * Closes #403
1 parent 0426c76 commit 08bdef4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

entries/height.xml

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
</p>
1515
<p>This method is also able to find the height of the window and document.</p>
1616
<pre><code>
17-
$( window ).height(); // returns height of browser viewport
18-
$( document ).height(); // returns height of HTML document
17+
// Returns height of browser viewport
18+
$( window ).height();
19+
20+
// Returns height of HTML document
21+
$( document ).height();
1922
</code></pre>
2023
<p>Note that <code>.height()</code> will always return the content height, regardless of the value of the CSS <code>box-sizing</code> property. As of jQuery 1.8, this may require retrieving the CSS height plus <code>box-sizing</code> property and then subtracting any potential border and padding on each element when the element has <code>box-sizing: border-box</code>. To avoid this penalty, use <code>.css( "height" )</code> rather than <code>.height()</code>.</p>
2124
<div class="warning">

entries/width.xml

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ $( window ).width();
2121
$( document ).width();
2222
</code></pre>
2323
<p>Note that <code>.width()</code> will always return the content width, regardless of the value of the CSS <code>box-sizing</code> property. As of jQuery 1.8, this may require retrieving the CSS width plus <code>box-sizing</code> property and then subtracting any potential border and padding on each element when the element has <code>box-sizing: border-box</code>. To avoid this penalty, use <code>.css( "width" )</code> rather than <code>.width()</code>.</p>
24+
<div class="warning">
25+
<p><strong>Note:</strong> Although <code>style</code> and <code>script</code> tags will report a value for <code>.width()</code> or <code>height()</code> when absolutely positioned and given <code>display:block</code>, it is strongly discouraged to call those methods on these tags. In addition to being a bad practice, the results may also prove unreliable.</p>
26+
</div>
2427
</longdesc>
2528
<note id="dimensions-number" type="additional" data-title=".width()"/>
2629
<example>

0 commit comments

Comments
 (0)