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?
}