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

  • Home
  • SEARCH
  • 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 8979499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:51:41+00:00 2026-06-15T19:51:41+00:00

I running into some performance issues with a jquery script I wrote when running

  • 0

I running into some performance issues with a jquery script I wrote when running in IE so I’m going through it trying to optimize any way possible. Apparently using for loops is way faster than using the jQuery .each method. This has led me to a question regarding the equivalent of $(this) inside a for loop. I’m simplifying what I’m doing in my loop down to just using an attr() function as it gets across my main underlying question.

Im doing this with each(simplified)

var existing = $('#existing').find('div');
    existing.each(function(){
    console.log($(this).attr('id'));
});

And I’ve tried rewriting it as a for loop as such:

var existing = $('#existing').find('div');
for(var i = 0;i < existing.length;i++)
{
    console.log(existing[i].attr('id'));
}

Its throwing an error saying:

Uncaught TypeError: Object #<HTMLDivElement> has no method 'attr'
  • 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-06-15T19:51:42+00:00Added an answer on June 15, 2026 at 7:51 pm

    You need existing.eq() to get jQuery object, existing[] gives you DOM object. The function attr() should be called with jQuery object but not with DOM (javascript) object.

    var existing = $('#existing');
    for(var i = 0;i < existing.length;i++)
    {
        console.log(existing.eq(i).attr('id'));
    }
    

    You can use each to get index without for loop.

    existing.each(function(index, item){
         alert(index);
         alert(item);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running into some positioning inconsistencies between browsers. I'm trying to position a submit
I'm running into some issues with having a lot of UIImages in memory, so
I am running into some slightly tricky issues with a legacy db. Everything seems
I have been trying to learn Erlang and have been running into some problems
I'm using Perl to perform some file cleansing, and am running into some performance
I'm frequently running into performance issues when I XSL transform large amounts of data
I am running into some performance issue and I have a query as follow:
I am trying to take a look into our database performance issues by making
I am running into some performance issue with php and mysql page. i have
I'm having some performance issues in a rails project (running on rails 2.0.5), for

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.