Rewriting HTML code using javascript
<p>I have some markup here that I need to reformat using javascript. Basically, I have this code:</p>

<pre><code>    &lt;div id="images"&gt;    
      &lt;img src="01.jpg"&gt;
      &lt;img src="02.jpg"&gt;
      &lt;img src="03.jpg"&gt;
      &lt;img src="04.jpg"&gt;
      &lt;a id="src" href="01.jpg"&gt;&lt;/a&gt;
      &lt;a id="src" href="02.jpg"&gt;&lt;/a&gt;
      &lt;a id="src" href="03.jpg"&gt;&lt;/a&gt;
      &lt;a id="src" href="04.jpg"&gt;&lt;/a&gt;
    &lt;/div&gt;
</code></pre>

<p>and I want javascript to rewrite the code so that the images are placed inside the anchors. Like this:</p>

<pre><code>    &lt;div id="images"&gt;    
      &lt;a id="src" href="01.jpg"&gt;&lt;img src="01.jpg"&gt;&lt;/a&gt;
      &lt;a id="src" href="02.jpg"&gt;&lt;img src="02.jpg"&gt;&lt;/a&gt;
      &lt;a id="src" href="03.jpg"&gt;&lt;img src="03.jpg"&gt;&lt;/a&gt;
      &lt;a id="src" href="04.jpg"&gt;&lt;img src="04.jpg"&gt;&lt;/a&gt;
    &lt;/div&gt;
</code></pre>

<p>any ideas?</p>
