Moving Images

I have recently been experimenting with javascript, for the development of a website. But there is one fundamental obstacle that is preventing me from making certail features: chaniging the position of images as the result of action. <br />
<br />
I tried using statements such as document.images[23].vspace=80, but unlike the src, width and height properties, the vspace and hspace properties cannot be altered in this way, it seems.<br />
<br />
I know it must by possible to move images, because i have seen it on other sites, so could anyone help and tell me how you can go about moving images? - thankyou<!--content-->I think what you're looking for is .style.top and .style.left.<!--content-->Ray's correct. Only one note: if you have a DOCTYPE in which triggers standards-compliance mode (e.g., HTML 4.01 Strict), be sure to specify the unit you'd like to use as well when setting properties such as this.<!--content-->thanx, but i tried that, and it didn't work, e.g. what is wrong with the following:<br />
<br />
<img src='http://www.webdeveloper.com/forum/archive/index.php/thing.jpg' width="35px" height="40px"><br />
<br />
<img src='http://www.webdeveloper.com/forum/archive/index.php/thing2.jpg' width="20px" height="30px" onclick="document.images[0].style.left=200"><br />
<br />
- this didn't work for me - what am I doing wrong?(thanx anyway)<!--content-->Firstly, the image must have the CSS rule position: absolute associated with it in order for you to dynamically set its position. Secondly, take careful note of my previous post.<!--content-->thanx very much, that worked perfectly.<br />
just one more problem:<br />
<br />
how do you alter the z-index of an image dynamically?<br />
(i need to make various images appear on top of oneanother, etc.),<br />
but using the statement: document.images[0].style.z-index=5<br />
does not work.<br />
<br />
Is it possible?<br />
<br />
thanx very much<!--content-->http://www.webxpertz.net/forums/showthread.php?t=26677<br />
<br />
In other words, use style.zIndex instead.<!--content-->
 
Back
Top