Replace images in a DIV using JavaScript
<p>I want to show different images in a DIV, the turn of an image depend on a random number.
The image name is like 1.gif, 2.gif, .. 6.gif</p>

<p>to do that I coded</p>

<pre><code>var img = document.createElement("IMG");
img.src = "images/1.gif";
document.getElementById('imgDiv').appendChild(img);
</code></pre>

<p>but it does not replace the old image how ever it add an another image right in the bottom of first image.</p>

<p>syntax for DIV is:</p>

<pre><code>&lt;div id="imgDiv" style="width:85px; height:100px; margin:0px 10px 10px 375px;"&gt;&lt;/div&gt;
</code></pre>

<p>may u halp me ?</p>
