Replace images in a DIV using javascript.
- by Muhammad Sajid
Hi,
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
to do that I coded
var img = document.createElement("IMG");
img.src = "images/1.gif";
document.getElementById('imgDiv').appendChild(img);
but it does not replace the old image how ever it add an another image right in the bottom of first image.
syntax for DIV is:
<div id="imgDiv" style="width:85px; height:100px; margin:0px 10px 10px 375px;"></div>
may u halp me ?