Click submit HTML <form onsubmit="return false"> Click submit <input id="btn" type="button" value="submit" onclick="$('#msg').html('you got me');"><br/> <div id="msg"></div> </form> CSS #btn { position: relative; } Javascript $(document).ready(function() { $('#btn').hover(function(e) { var $el = $('#btn'), offset = $el.offset(), newtop = offset.top + 25 - Math.random()*50, newleft = offset.left + 25 - Math.random()*50; $el.offset({top: newtop, left: newleft}); }); });