<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>鼠标拖动图片移动</title> <script type="text/javascript" src="js/jquery-1.11.3.js"></script> <script type="text/javascript"> $(function(){ $("html").mousemove(function(e){ $("#a").css("left",e.pageX).css("top",e.pageY); }); }); </script> <style type="text/css"> .a { width:200px; height:100px; position:absolute; background-color:rgb(0,0,0); } </style> </head> <body> <img src="img/duihuan.png" id="a" name="a" class="a" > 只做了一个简单的实例 </body> </html>
时间: 2024-10-24 00:53:19