<!doctype html> <html> <head> <meta charset="utf-8"> <title>Jquery</title> <style> body{height:3000px; background:#09F;} .wenzi{position:absolute; left:0; top:0;} p{cursor:pointer;} </style> <script src="jquery.js" type="text/javascript"></script> <script> $(function(){ $(document).mousemove(function(e){var x=e.pageX-$('p').width()/2; //获取鼠标的x坐标 var y=e.pageY-$('p').height()/2-10; //获取鼠标的y坐标 $('.wenzi').css({'left':x,'top':y},1000) }); }) </script> </head> <body> <p class='wenzi'>这是一段文字</p> </body> </html>