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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:14:00+00:00 2026-05-14T07:14:00+00:00

For example, I have a website which has a dynamically-generated segment of its dom

  • 0

For example, I have a website which has a dynamically-generated segment of its dom which looks roughly like this:

<div id="master">
  <div class="child"> ... </div>
  <div class="child"> ... </div>
  <div class="child"> ... </div>
  ...
  <div class="child"> ... </div>
</div>

There might be hundreds of child elements in this manner, and they, too, might have yet more children. At present, none of them have id’s except for the master. Javascript manipulates them via dom-walking. It’s a little scary.

I’d like to add id’s, e.g.:

<div id="master">
  <div id="child1" class="child"> ... </div>
  <div id="child2" class="child"> ... </div>
  <div id="child3" class="child"> ... </div>
  ...
  <div id="childN" class="child"> ... </div>
</div>

What are the tradeoffs in adding id’s to these divs? Certainly, jQuery must maintain a hash of id’s, so there’s going to be some sort of performance hit. Any general guidelines in when adding additional id’s is a bad idea? Is jQuery so awesome that, in practice, it doesn’t matter?

  • 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-14T07:14:00+00:00Added an answer on May 14, 2026 at 7:14 am

    Certainly, jQuery must maintain a hash of ids

    Nope. It’s the browser that (optionally, as an optimisation) keeps a lookup of id to node.

    If you interact with objects in a way that causes jQuery to add data to an element (including if you add an event listener), then it will add its own jquery-id to the element for lookup purposes. But it’ll do that regardless of whether the element has an id attribute.

    Add id​s if you need to pick out a particular element from the rest. But there’s no point in adding childN attributes to every child when you already have classes. The selector #master>.child is likely to be faster than #master>[id^=child], and certainly much faster than fetching each idN separately in a loop.

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

Sidebar

Related Questions

I have a website which has .htaccess rewrite rules. And alot of them. This
I have a website(for example: test.com), which has 2 kinds of subdomains: test.com static_${version}.test.com
I have a website already running made with CakePHP, which has its own login
I use Java Applet like an example. When you open a website which has
For example I have a website that points to a page like this: http://www.mysite.com/folder/file
I need to crawl a website, which basically has links like this: www.website.com/link/page_1.html www.website.com/link/page_2.html
I have updated my website. Previously there were links like these: http://example.com/bla-bla-bla?language=de . After
I have an MVC website which has 3 main components Member area which has
i have made a company website which has the MYSQL database of accounting,inventory,expenses, etc.
I am making an auction website, which has an auto-bid system. This system lets

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.