Replace images in a DIV using javascript.
        Posted  
        
            by Muhammad Sajid
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Muhammad Sajid
        
        
        
        Published on 2010-05-27T19:25:50Z
        Indexed on 
            2010/05/27
            19:31 UTC
        
        
        Read the original article
        Hit count: 335
        
JavaScript
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 ?
© Stack Overflow or respective owner