This works without a built-in script in all browsers
Codepen demo
var object = document.getElementById('item'); object.onclick=function(){ var x = Math.floor(Math.random()*300); var y = Math.floor(Math.random()*300); object.style.top = x + 'px'; object.style.left = y + 'px'; };
HTML
<img id="item" src="http://...png" />
CSS
#item { cursor: pointer; position: absolute; top: 0px; left: 0px; transition: all 1s; }
source share