tags:

views:

42

answers:

1

I am looking for a simple script to move an image in JavaScript. Code examples from Google search results are not working for me.

Please help.

+3  A: 

To directly answer your question, this script will move an image 42 pixels below and 42 pixels to the right of your absolutely-positioned parent (provided that the image was not already in that position).

var img = document.getElementById("IDImage");
img.style.position = "absolute"; // You should style this with CSS, not this script
img.style.top = 42 + "px";
img.style.left = 42 + "px";
palswim
Thank you palswim!!! this was very helpful and worked right away. You are a great SO citizen.
dotnet-practitioner