Finding a list of elements in Javascript
<p>I've created a function that creates a new img and puts it in every tag which has the css class "painted":</p>

<pre><code>function putPiece(){
    var painted = document.querySelectorAll('.painted');

for (var i = 0, len = painted.length; i &lt; len; i++) {
    var a = i+1
    var squareID = painted[i].id;
    painted[i].taken = 'BP'+a;

    var img = document.createElement("img");
    painted[i].appendChild(img);
    img.id = "BP"+a; //unique ID for every img
    img.src = "blackP.png"; //the image to use
    img.pstn = squareID; //the ID of the &lt;td&gt; it's in


}
}
</code></pre>

<p>Iv'e given properties to each object, as noted above.
Now I would like to create an array that would contain the "img.pstn" of all the "img" objects.
Any ideas? thanks ahead!</p>
