Bug Tracker

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:


I think it should be possible to pass an array of DOM elements to jQuery() as context.



<div id="a">
  <span class="book">
<div id="b">
  ... some html...
<div id="c">
  <span class="book">
<div id="d">
  ... some html...


var a = $('#a'),
    c = $('#c');


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 silesianlordt

Sorry should be:




comment:2 Changed 12 years ago by Rick Waldron

Component: unfiledcore
Owner: set to silesianlordt
Priority: undecidedlow
Status: newpending

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

comment:3 Changed 12 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

comment:4 Changed 12 years ago by Rick Waldron

Resolution: wontfix
Status: pendingclosed


Note: See TracTickets for help on using tickets.