Opened 12 years ago
Closed 12 years ago
#9245 closed feature (wontfix)
An array as jQuery context argument
Reported by: | silesianlordt | Owned by: | silesianlordt |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | core | Version: | 1.6rc1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I think it should be possible to pass an array of DOM elements to jQuery() as context.
Example:
HTML:
<div id="a"> <span class="book"> </div> <div id="b"> ... some html... </div> <div id="c"> <span class="book"> </div> <div id="d"> ... some html... </div>
JS:
var a = $('#a'), c = $('#c'); $('.book',[a,b]).hide();
I know there are different ways to do what I've done above. I want to show simple example.
Change History (4)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → core |
---|---|
Owner: | set to silesianlordt |
Priority: | undecided → low |
Status: | new → pending |
Isn't that the same as... $(".book").hide();
comment:3 Changed 12 years ago by
In recent discussions, the team has been resistant to add additional signatures to the main jQuery() function. In general, the context argument is just a long-path to $(context).find("selector"), so adding additional type checking into the main jQuery function to test for an array of dom elements as CONTEXT, when an array of DOM elements is already an existing signature and you could simply do $([a,b]).find(".foo");
Also worth noting is that your example does not actually use an array of DOM elements as the context, it tries to use an array of jQuery objects as the context, which I tend to think we're even less inclined to support - as either the first or second argument to jQuery - see #9011
Sorry should be:
not