开发者

javascript: move image upon button click

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";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜