#12889 closed feature (plugin)
Add .cousin() support
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This would be shorthand for .parents().siblings().children()
Change History (3)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Resolution: | → plugin |
---|---|
Status: | new → closed |
Thanks for your time and interest in helping out with jQuery Core! Unfortunately, I can't see us adding this to the API surface. There's syntactic sugar, and then there's syntactic saccharin: overly concentrated sweetness that isn't really good for you anyway. The language of children, siblings, parents, etc. is codified in the DOM APIs, whereas "cousin" is just extending that metaphor in a nebulous way. As proposed, this method only gets "first cousins." What if people want second cousins, or fourth cousins twice-removed? This opens up a can of worms that I can't foresee us wanting to deal with.
In other words, this type of functionality or any other custom traversal methods are best reserved for a plugin at this point :)
Example... I have a structure like:
I want to move the error into a tooltip to the right of the last input in the div. $(".error").cousins(":input").last() would be the most efficient way of finding this, or at least more so than $(".error").parent().siblings().children(":input").last() or $(".error").parent().next("div").children(":input").last()