87,994
社区成员
发帖
与我相关
我的任务
分享
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> 页面名称 </title>
</head>
<body>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<img id="img" src="1.png" width="100" height="100" border="0" style="position: absolute;">
<script type="text/javascript">
var img = $("#img");
function move() {
img.stop(true).animate({
left: Math.floor(Math.random()*($(document).width()-img.width())),
top: Math.floor(Math.random()*($(document).height()-img.height()))
}, 3000, move);
}
img.click(function(event){
move();
});
move();
</script>
</body>
</html>