Skip to content

Commit ce171d6

Browse files
committed
Clarified that closest() returns 0 or 1 element /per original element/.
1 parent 8fc8322 commit ce171d6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

entries/closest.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
</argument>
2929
</signature>
3030

31-
<desc>Get the first element that matches the selector, beginning at the current element and progressing up through the DOM tree.</desc>
31+
<desc>For each element in the set, get the closest element that matches the selector, by testing the element itself and traversing up through its ancestors.</desc>
32+
3233
<longdesc><p>Given a jQuery object that represents a set of DOM elements, the <code>.closest()</code> method searches through these elements and their ancestors in the DOM tree and constructs a new jQuery object from the matching elements. The <code>.parents()</code> and <code>.closest()</code> methods are similar in that they both traverse up the DOM tree. The differences between the two, though subtle, are significant:</p>
3334

3435
<table>
@@ -47,8 +48,8 @@
4748
<td>Travels up the DOM tree to the document's root element, adding each ancestor element to a temporary collection; it then filters that collection based on a selector if one is supplied </td>
4849
</tr>
4950
<tr>
50-
<td>The returned jQuery object contains zero or one element</td>
51-
<td>The returned jQuery object contains zero, one, or multiple elements</td>
51+
<td>The returned jQuery object contains zero or one element for each element in the original set</td>
52+
<td>The returned jQuery object contains zero or more elements for each element in the original set</td>
5253
</tr>
5354
</tbody>
5455
</table>

0 commit comments

Comments
 (0)