Skip to content

siblings: explain, that original elements might be returned, too #678

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

Closed
wants to merge 2 commits into from

Conversation

Boldewyn
Copy link
Contributor

This edit is motivated by jquery/jquery#2149. It might come as surprise, that $(':even').siblings() != $(':odd'). This commit explains this behaviour and how to create a disjunct set, if needed.

I have already signed the CLA.

@Boldewyn
Copy link
Contributor Author

It seems, I've signed the CLA before with another email address. I have now used the one from this commit header to re-sign.

@dmethvin
Copy link
Member

Seems like a reasonable clarification!

@@ -26,7 +26,7 @@
$( "li.third-item" ).siblings().css( "background-color", "red" );
</code></pre>
<p>The result of this call is a red background behind items 1, 2, 4, and 5. Since we do not supply a selector expression, all of the siblings are part of the object. If we had supplied one, only the matching items among these four would be included.</p>
<p>The original element is not included among the siblings, which is important to remember when we wish to find all elements at a particular level of the DOM tree.</p>
<p>The original element is not included among the siblings, which is important to remember when we wish to find all elements at a particular level of the DOM tree. However, if the original set contains more than one element, they might be mutual siblings and will both be found. If you need an exclusive list of siblings, use <code>$set.siblings().not($set)</code>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick about the wording: In general we've been using collection or just jQuery object, not set in most of the documentation. Especially since these days set might confuse beginners (ES6 Sets, Angular $set method, ...)

@Boldewyn
Copy link
Contributor Author

I updated the wording. Thanks, @arthurvr!

@arthurvr
Copy link
Member

Thanks! Good to land I think?

@arthurvr arthurvr closed this in 165bc39 Mar 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants