Changing the ID of all "div" elements (Javascript)
<p>As the title says, I'm trying to change the ID of all elements with the tag "div". Here's my current script, which does not work:</p>

<pre><code>function setIDs() {
    var divs[] = new Array();
    for(i in document.getElementsByTagName('div'))
        divs[i] = document.getElementsByTagName('div')[i];
    for(idNum in divs) divs[idNum].id="child"+idNum;
}
</code></pre>

<p>So after setIDs() is finished, my HTML should look like this:</p>

<pre><code>&lt;div id="child0"&gt;...&lt;/div&gt;
&lt;div id="child1"&gt;...&lt;/div&gt;
...
&lt;div id="childn"&gt;...&lt;/div&gt;
</code></pre>
