Skip to main content

Bug Tracker

Side navigation

#9245 closed feature (wontfix)

Opened May 11, 2011 09:17PM UTC

Closed May 12, 2011 02:48AM UTC

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.

Attachments (0)
Change History (4)

Changed May 11, 2011 09:43PM UTC by silesianlordt comment:1

Sorry should be:

$('.book',[a,c]).hide();

not

$('.book',[a,b]).hide();

Changed May 12, 2011 12:56AM UTC by rwaldron comment:2

component: unfiledcore
owner: → silesianlordt
priority: undecidedlow
status: newpending

Isn't that the same as... $(".book").hide();

Changed May 12, 2011 01:12AM UTC by ajpiano comment:3

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

Changed May 12, 2011 02:48AM UTC by rwaldron comment:4

resolution: → wontfix
status: pendingclosed

+1