I have JS generated html part, that looks like this:
<div id="container">
<div id="block_1" class="blocks"></div>
<div id="block_2" class="blocks"></div>
<div id="block_3" class="blocks"></div>
...
<div id="block_n" class="blocks"></div>
</div>
I am looping through them like this:
var blocks = $(".blocks");
$.each(blocks, function() {
var val = $(this).text();
...
});
But I can also go:
for (var i=1; i<=block_count; i++) {
var val = $("#block_"+i).text();
...
}
So the question is: Which way would be better performance-wise and is there any significant difference?
And maybe there is another - better way?!
max block count is about 10`000, but it's theoretically infinite. It grows during the game.