Skip to content

Clarified that closest() returns 0 or 1 element /per original element/. #26

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

Merged
merged 1 commit into from
Jun 3, 2012
Merged
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
7 changes: 4 additions & 3 deletions entries/closest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
</argument>
</signature>

<desc>Get the first element that matches the selector, beginning at the current element and progressing up through the DOM tree.</desc>
<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>

<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>

<table>
Expand All @@ -47,8 +48,8 @@
<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>
</tr>
<tr>
<td>The returned jQuery object contains zero or one element</td>
<td>The returned jQuery object contains zero, one, or multiple elements</td>
<td>The returned jQuery object contains zero or one element for each element in the original set</td>
<td>The returned jQuery object contains zero or more elements for each element in the original set</td>
</tr>
</tbody>
</table>
Expand Down