Skip to content

Commit 1a24f77

Browse files
committed
Clarify difference in .parent() vs .parents(). Close gh-293.
1 parent 0678938 commit 1a24f77

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

entries/parent.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
</signature>
1010
<desc>Get the parent of each element in the current set of matched elements, optionally filtered by a selector.</desc>
1111
<longdesc>
12-
<p>Given a jQuery object that represents a set of DOM elements, the <code>.parent()</code> method allows us to search through the parents of these elements in the DOM tree and construct a new jQuery object from the matching elements. The <a href="/parents/"><code>.parents()</code></a> and <code>.parent()</code> methods are similar, except that the latter only travels a single level up the DOM tree.</p>
12+
<p>Given a jQuery object that represents a set of DOM elements, the <code>.parent()</code> method allows us to search through the parents of these elements in the DOM tree and construct a new jQuery object from the matching elements.</p>
13+
<p>The <code>.parents()</code> and <code><a href="http://api.jquery.com/parent/">.parent()</a></code> methods are similar, except that the latter only travels a single level up the DOM tree. Also, <code>$("html").parent()</code> method returns a set containing <code>document</code> whereas </code>$("html").parents()</code> returns an empty set.</p>
1314
<p>The method optionally accepts a selector expression of the same type that we can pass to the <code>$()</code> function. If the selector is supplied, the elements will be filtered by testing whether they match it.</p>
1415
<p>Consider a page with a basic nested list on it:</p>
1516
<pre><code>

entries/parents.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
</signature>
1010
<desc>Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.</desc>
1111
<longdesc>
12-
<p>Given a jQuery object that represents a set of DOM elements, the <code>.parents()</code> method allows us to search through the ancestors of these elements in the DOM tree and construct a new jQuery object from the matching elements ordered from immediate parent on up; the elements are returned in order from the closest parent to the outer ones. The <code>.parents()</code> and <code><a href="http://api.jquery.com/parent/">.parent()</a></code> methods are similar, except that the latter only travels a single level up the DOM tree.</p>
12+
<p>Given a jQuery object that represents a set of DOM elements, the <code>.parents()</code> method allows us to search through the ancestors of these elements in the DOM tree and construct a new jQuery object from the matching elements ordered from immediate parent on up; the elements are returned in order from the closest parent to the outer ones.</p>
13+
<p>The <code>.parents()</code> and <code><a href="http://api.jquery.com/parent/">.parent()</a></code> methods are similar, except that the latter only travels a single level up the DOM tree. Also, <code>$("html").parent()</code> method returns a set containing <code>document</code> whereas <code>$("html").parents()</code> returns an empty set.</p>
1314
<p>The method optionally accepts a selector expression of the same type that we can pass to the <code>$()</code> function. If the selector is supplied, the elements will be filtered by testing whether they match it.</p>
1415
<p>Consider a page with a basic nested list on it:</p>
1516
<pre><code>

0 commit comments

Comments
 (0)