how to separate one array into two, base on its id using jquery <p>Im strugling with this array:</p> <p>first id = 1</p> <p>items for the second id = 12,21,34,33; </p> <p>second id = 2</p> <p>items for the second id = 21,12,34</p> <p>It looks like this in my array : </p> <p>arr = [12 1,21 1,34 1,33 1,21 2,12 2,34 2]</p> <p>i want to store it like this:</p> <p>id | item_id</p> <p>1 12</p> <p>1 21</p> <p>1 34</p> <p>1 33</p> <p>2 21</p> <p>2 12</p> <p>2 34</p> <p>here's my code :</p> <p>var item_id = new Array();</p> <p>$("td.items").each(function() {</p> <p>if(this){</p> <p>item_id.push($(this).attr('id'));</p> <p>}</p> <p>});</p>