Ticket #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: | ||
| Blocking: | Blocked by: |
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
comment:2 Changed 2 years ago by rwaldron
- Owner set to silesianlordt
- Priority changed from undecided to low
- Status changed from new to pending
- Component changed from unfiled to core
Isn't that the same as... $(".book").hide();
comment:3 Changed 2 years ago by ajpiano
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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Sorry should be:
$('.book',[a,c]).hide();not
$('.book',[a,b]).hide();