How do i make a allocation table?
<p>I have build a grid of div's as playground for some visual experiments. In order to use that grid, i need to know the x and y coordinates of each div. That's why i want to create a table with the X and Y position of each div.</p>

<p>X:0 &amp; Y:0 = div:eq(0), X:0 Y:1 = div:eq(1), X:0 Y:2 = div:eq(2), X:0 Y:3 = div:eq(3), X:1 Y:0 = div:eq(4) etc..</p>

<p>What is the best way to do a table like that? Creating a OBJECT like this:</p>

<p>{
   00: 0,
   01: 1,
   02: 2,
   etc..
}</p>

<p>or is it better to create a array?</p>

<p>position[0][0] = 0</p>

<p>the thing is i need to use the table in multiple way's.. for example the user clicked the div nb: 13 what are the coordinates of this div or what is the eq of the div x: 12 y: 5.</p>

<p>Thats how i do it right now:</p>

<pre><code>        var row = 0
    var col = 0
    var eq = 0      

    c.find('div').each(function(i){ // c = $('div#stage')

        if (i !=0 &amp;&amp; $(this).offset().top != $(this).prev().offset().top){
            row++
            col = 0
        }

        $(this).attr({'row': row, 'col': col })

        col++

    })
</code></pre>

<p>I think it would be faster to build a table with the coordinates, instead of adding them as attr or data to the DOM. but i cant figure out how to do this technically. </p>

<p>How would you solve this problem width JS / jQuery?</p>
