JSFiddle - React, Tailwind, and code Playground
HTML
<img src="http://aoifeodwyer.com/box/img.gif" width="100" height="100" alt="Grey Square" id="pee" />
CSS
body { position: relative; }
#img { position: relative; }
JavaScript
jQuery(function($) {
$('#pee').mouseover(function() {
var dWidth = $(document).width() - 100, // 100 = image width
dHeight = $(document).height() - 100, // 100 = image height
nextX = Math.floor(Math.random() * dWidth),
nextY = Math.floor(Math.random() * dHeight);
$(this).animate({ left: nextX + 'px', top: nextY + 'px' });
});
$('#pee').mouseout(function() {
$(this).animate({ left: '0', top: '0', position: 'relative' });
});
});