Javascript examples for DOM HTML Element:Image
move an image to the mouse position in html/javascript
<html> <head></head> <body> <img id="avatar" src="http://www.java2s.com/style/download.png" style="position:absolute;"> <script lang="javascript"> function updateAvatarPosition( e ) { var avatar = document.getElementById("avatar"); avatar.style.left = e.x + "px"; avatar.style.top = e.y + "px"; console.log( "e( " + e.x + ", " + e.y + " )" ); console.log( "avatar( " + avatar.x + ", " + avatar.y + " )" ); } document.onmousemove = updateAvatarPosition; </script> </body>//from ww w. ja va2 s . c o m </html>