Here is my code: function OrbCreator(){ var b; b=document.createElement("<img src='./images/Orb.png' style='position:absolute; display:none; left:10000px; top:0px; width:"+(2*Orbsize)+"px; height:"+(2*Orbsize)+"px;'>"); this.is=b.style; this.src=b.src; this.move=moveOrb; document.getElementById("container").appendChild(b); this.is.display='block'; } function moveOrb(x,y,z){ this.is.width=2*Os; this.is.height=2*Os; this.is.left=x-Os; this.is.top=y-Os; this.is.zIndex=z; if(this.renew==true){ this.renew=false; this.src="./images/NewImage.png"; } if(document.getElementById('message').style.top>0){ document.getElementById('message').style.top=document.getElementById('message').style.top-1; } } Code (markup): What am I doing wrong? P.S. site url: http://huduzu.trollnest.com
this.src="./images/NewImage.png"; Code (markup): I didn't test the code, but this line wouldn't change the src of the picture if that's what you expect... In the scope you are calling it, "this" refers to the moveOrb function. Either create the moveOrb as a prototype of OrbCreator, so you can have access to the img from within the function, or set an id to the pic and use it in moveOrb with something like this: document.getElementById('myPicId').src = './images/NewImage.png'; Code (markup):