<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>跟随鼠标移动实例</title>
<style type="text/css">
body,h1,h2,h3,h4,h5,h6,dl,dt,dd,ul,ol,li,th,td,p,pre,form,input,button{margin:0; padding:0;}
table{border-collapse:collapse;border-spacing:0;}
h2{font-size:14px;}
ul,ol{list-style:none;}
body{font-size:14px;/*width:320px;*/margin:0 auto;color:#6c6c6c; font-family:"微软雅黑",Helvetica;}
fieldset,img{border:0;}
img{/*vertical-align:middle;*/}
input,textarea{ border:none 0;}
a{text-decoration:none; color:#666;}
.box{position:absolute;width:100px; height:50px; }
.span{width:10px; height:10px; background:#CCCCCC;position:absolute;}
</style>
</head>
<body>
<div class="box"></div>
<div class="span"></div>
</body>
<script type="text/javascript" src="js/jquery-1.4.2.min.js" >//需要加入JQ</script>
<script language="javascript" type="text/javascript">
$(function(){
$(document).mousemove(function(e){
a=e.pageX;
b=e.pageY;
$(".box").text(a+" "+b)
$(".span").animate({left:(e.pageX-10)+"px",top:(e.pageY-10)+"px"},0.000001)
})
})
</script>
</html>