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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:20:34+00:00 2026-05-13T11:20:34+00:00

I have loaded a table of data into an HTML page so that it

  • 0

I have loaded a table of data into an HTML page so that it looks like this:

<div id="objList" style="display:none">
    <div class="objRecord">
        <div class="objID">6846</div>
        <div class="objColor">blue</div>
        <div class="objSize">500</div>
        <div class="objType">Q</div>
    </div>
    ...
    <div class="objRecord">
        <div class="objID">6877</div>
        <div class="objColor">green</div>
        <div class="objSize">600</div>
        <div class="objType">T</div>
    </div>
</div>

The reason that I’ve done it this way is because it’s a relatively small amount of data and I don’t want the page to be “chatty” and go back to the server (ajax) for new data on each event.

I will be querying that table of data based on user events on the page.

My questions:
1. Is there anything wrong with that structure for retrieving records using jQuery? How would you do it? I was thinking that I could also use a table + tr + td structure for the data but can’t see the advantage to that – yet…
2. How would I, for example, get the sizes for all the blue objects from the table with jQuery?

I can get all the blue records in the table using:

var myobjects = $('.objRecord .objColor:contains("blue")').parent();

But I am now struggling to get the size value out of that array…

for (var i = 0; i < myobjects.length; i++) {
    var x = myobjects[i]; // somehow get the size out of this?
}
  • 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-13T11:20:35+00:00Added an answer on May 13, 2026 at 11:20 am

    You could do a single iteration over the table when the page first loads, and move the data into an array of JavaScript object literals:

    $(document).ready(function(){
       var data = [];
       $('#objList .objRecord').each(function(){
         var  $this = $(this),
             record = {
               ref: $this,
               objID:    Number($this.find('.objID').text()),
               objColor: $this.find('.objColor').text(),
               objSize:  Number($this.find('.objSize').text()),
               objType:  $this.find('.objType').text()
             };
    
         data.push(record);
         $this.data('record', record);
       });
    });
    

    This happens once; now subsequent queries will be executed against a much faster JavaScript array, than against the DOM tree.

    To get an array of all the sizes:

    var sizes = $.map(data, function(d){ return d.objSize });
    

    The nice thing is, you stored a double reference. So you can access it from the DOM node in the case where you might get it from a click event:

    $('.objSize').click(function(){
      // Find the parent `.objRecord` then call its data function
      var record =  $(this).closest('.objRecord').data('record');
    
      alert(record.objType);
    })
    

    And it can be retreived from the JavaScript object:

    var record = data[0]; // first record
    record.ref.hide(); // Hides the `.objRecord` associated with this record.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have CSV data loaded into a multidimensional array. In this way each row
I have written a web service that returns some data as json. To display
I have a JTable which is loaded from a data-structure using table model.The data-structure
I have loaded image into a new, initialized Oracle ORDImage object and am processing
I have an EXE loaded into a byte array, and I am trying to
I have a page being loaded with jQuery. The initial load includes 100 records
I have an XML file loaded into a DOM document, I wish to iterate
I have a custom aspx page loaded in a IFrame in one of the
I have an excel sheet that is loaded with a dynamic result set of
I have a script that appends some rows to a table. One of the

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.