Side navigation
#12889 closed feature (plugin)
Opened November 13, 2012 10:36PM UTC
Closed November 13, 2012 11:42PM UTC
Last modified November 14, 2012 01:14AM UTC
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()
Attachments (0)
Change History (3)
Changed November 13, 2012 10:47PM UTC by comment:1
Changed November 13, 2012 11:42PM UTC by comment:2
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 :)
Changed November 14, 2012 01:14AM UTC by comment:3
Agreed.
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()