Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6614557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:21:11+00:00 2026-05-25T20:21:11+00:00

Yeah, the way I was doing is A.add(B).add(C).add(D).show() While A,B,C,D are jQuery objects. I

  • 0

Yeah, the way I was doing is

   A.add(B).add(C).add(D).show()

While A,B,C,D are jQuery objects. I wonder if there’s such a simpler way to do this out there?
I’ve tried all the following approaches, but no results:

$(A,B,C,D).show()
A.add(B,C,D).show()

All suggestions are welcome!


Addition to clarify the question:

The part “.show()” is just for demonstration. I just wanted to know how could I create a set of JQuery object like $(‘p’) create a set of p tag.

In my real case, I used

$([A,B,C,D]).each(fn)

instead of .show() (And I wonder why this worked?)
It’s obviously that

$([A,B,C,D]).each(fn)
$('p').each(fn)

both work. But

$([A,B,C,D]).show()  //--doesn't work
$('p').show()        //--works

Just the second line works. Does anyone know the diffrence between them ?
(I just thought they’re the same, then made a bit of tangle in my question)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:21:12+00:00Added an answer on May 25, 2026 at 8:21 pm
    $.each([A,B,C,D], function(){ 
        $(this).css('background','red'); 
    })
    

    Instead of using a selector this solution uses a jQuery method called $.each which takes an array and iterates over it. The array passed is a set of jQuery objects. $(this) referes to the jQuery objects being iterated on each time.

    demo: http://jsfiddle.net/SCjMc/1/


    Other facts about how $() works:

    $(element) is an shortcut for jQuery(element). The jQuery() method accepts a different set of parameters:

    enter image description here

    The description for each type of parameter can be found in this link.

    One of the type of parameters is “elementArray”. The description for this is:

    elementArray An array containing a set of DOM elements to wrap in a jQuery object.

    The catch is that when you use jQuery to select an element this returns a jQuery object and not a DOM Element directly. Therefore this will not return any elements:

    var element1 = $("selector1");
    var element2 = $("selector2");
    $([element1,element2]) // will not return any elements
    

    To return a DOM Element instead of a jQuery object you have to access the property in the position of 0 of the jQuery object. As follows: $("element")[0]. And that is why this will work:

    var element1 = $("selector1")[0]; //accessing dom element 
    var element2 = $("selector2")[0]; //from jQuery object
    $([element1,element2])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might sound dumb but yeah i need a effective way of doing this.
So yeah, I'm just trying to see if there is a more elegant way
Yeah, I was wondering if there's a way to make a link the size
Yeah, this is indeed my third or fourth question about jQuery UI Autocomplete. My
Yeah, its a bit on this side of pointless, but I was wondering... I've
Yeah this works in FF and Chrome, but for some reason wont work in
So yeah, I'm a Java guy in this crazy iPhone world. When it comes
So yeah, like I said, I've spent a few hours trying to fix this
In Linux (Bash) there is a very useful functionality for dumping literal text out
Is there a simple way to check if all values in array are equal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.