I am looking for a simple script to move an image in JavaScript. Code examp开发者_高级运维les from Google search results are not working for me.
Please help.
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";
精彩评论