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 4019636
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:07:44+00:00 2026-05-20T10:07:44+00:00

Suppose I get a list of items like $(.box) . Is it possible to

  • 0

Suppose I get a list of items like $(".box"). Is it possible to get an indexed jQuery object

like

var $boxes = $(".box"),
    $box2 = $boxes[1]

currently I do something like

var $boxes = $(".box");
$boxes.each(function(i, box) {
    var $box = $(box); // <-- is this a good idea?
    // do something with $box
});

I wonder tho if the line var $box = $(box) is such a good idea? I am actually running that in a setInterval()

like

var $boxes = $(".box");
setInterval(function() {
    $boxes.each(function(i, box) {
        var $box = $(box); // <-- is this a good idea?
        // do something with $box
    });
}, 1000);

I wonder if its bad for performance since I am initializing a variable for each item in $boxes per 1s in this example. If I can access the element directly from the jQuery “array” or whatever $boxes is, it maybe better?

  • 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-20T10:07:44+00:00Added an answer on May 20, 2026 at 10:07 am

    You can iterate though the jQuery elements as per your example, nothing wrong with that. Creating a local variable for each element var $box = $(box); is a good idea.

    You can also access the elements of the jQuery object with the eq method, e.g:

    var $boxes = $(".box"),
    $box2 = $boxes.eq(1);
    

    That way you don’t need to pass the element through the $ constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets suppose I have a RESTful service which has a list of tasks. GET
Suppose I get, on a page, this simple html/script : <a id=hey href=#>try</a> var
Suppose I have a class like this: public class ThingManager { List<SomeClass> ItemList; public
Consider this Django view which will get a list of items associated to the
I want create a web application that display a list of items. Suppose I
Suppose I have a container containing a list of items, so the markup looks
I have one simple app that suppose to get information from user and send
A quick question regarding the java.lang.VerifyError exception. Suppose I get an error that looks
According to Apple's description, the aurioTouch sample app is suppose to get the audio
How to get file size of pdf,gif,doc etc using xcode. suppose to i get

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.