Skip to content

Commit 28884e3

Browse files
authored
Offset: Be more precise about the origins for .offset() and .position()
Ref jquery/jquery#3487 Closes jquerygh-1027
1 parent 06e4ce4 commit 28884e3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

entries/offset.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</signature>
99
<desc>Get the current coordinates of the first element in the set of matched elements, relative to the document.</desc>
1010
<longdesc>
11-
<p>The <code>.offset()</code> method allows us to retrieve the current position of an element <em>relative to the document</em>. Contrast this with <code><a href="/position/">.position()</a></code>, which retrieves the current position <em>relative to the offset parent</em>. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), <code>.offset()</code> is more useful.</p>
11+
<p>The <code>.offset()</code> method allows us to retrieve the current position of an element (specifically its border box, which excludes margins) <em>relative to the document</em>. Contrast this with <code><a href="/position/">.position()</a></code>, which retrieves the current position <em>relative to the offset parent</em>. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), <code>.offset()</code> is more useful.</p>
1212
<p><code>.offset()</code> returns an object containing the properties <code>top</code> and <code>left</code>.</p>
1313
<div class="warning">
14-
<p><strong>Note:</strong> jQuery does not support getting the offset coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.</p>
14+
<p><strong>Note:</strong> jQuery does not support getting the offset coordinates of hidden elements or accounting for margins set on the <code>&lt;html&gt;</code> document element.</p>
1515
<p>While it is possible to get the coordinates of elements with <code>visibility:hidden</code> set, <code>display:none</code> is excluded from the rendering tree and thus has a position that is undefined.</p>
1616
</div>
1717
</longdesc>
@@ -96,7 +96,7 @@ $( "*", document.body ).click(function( event ) {
9696
</signature>
9797
<desc>Set the current coordinates of every element in the set of matched elements, relative to the document.</desc>
9898
<longdesc>
99-
<p>The <code>.offset()</code> setter method allows us to reposition an element. The element's position is specified <em>relative to the document</em>. If the element's <code>position</code> style property is currently <code>static</code>, it will be set to <code>relative</code> to allow for this repositioning.</p>
99+
<p>The <code>.offset()</code> setter method allows us to reposition an element. The element's border-box position is specified <em>relative to the document</em>. If the element's <code>position</code> style property is currently <code>static</code>, it will be set to <code>relative</code> to allow for this repositioning.</p>
100100
</longdesc>
101101
<example>
102102
<desc>Set the offset of the second paragraph:</desc>

entries/position.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
</signature>
77
<desc>Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.</desc>
88
<longdesc>
9-
<p>The <code>.position()</code> method allows us to retrieve the current position of an element <em>relative to the offset parent</em>. Contrast this with <code><a href="/offset/">.offset()</a></code>, which retrieves the current position <em>relative to the document</em>. When positioning a new element near another one and within the same containing DOM element, <code>.position()</code> is the more useful.</p>
9+
<p>The <code>.position()</code> method allows us to retrieve the current position of an element (specifically its margin box) <em>relative to the offset parent</em> (specifically its padding box, which excludes margins and borders). Contrast this with <code><a href="/offset/">.offset()</a></code>, which retrieves the current position <em>relative to the document</em>. When positioning a new element near another one and within the same containing DOM element, <code>.position()</code> is the more useful.</p>
1010
<p>Returns an object containing the properties <code>top</code> and <code>left</code>.</p>
1111
<div class="warning">
12-
<p><strong>Note:</strong> jQuery does not support getting the position coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.</p>
12+
<p><strong>Note:</strong> jQuery does not support getting the position coordinates of hidden elements or accounting for margins set on the <code>&lt;html&gt;</code> document element.</p>
1313
</div>
1414
</longdesc>
1515
<note id="dimensions-number" type="additional" data-title=".position()"/>

0 commit comments

Comments
 (0)