<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> #fk{ width: 50px; height: 50px; background: deepskyblue; position: absolute; } </style> </head> <body> <div id="fak"></div> </body> <script> var oDiv=document.getElementById("fak"); oDiv.onmousedown=function () { document.onmousemove=function (ev) { var event=window.event||ev; oDiv.style.top=event.clientY+"px"; oDiv.style.left=event.clientX+"px"; }; document.onmouseup=function () { document.onmouseup=null; document.onmousemove=null; } } </script> </html>
方块拖动
猜你喜欢
转载自blog.csdn.net/frost666/article/details/80849338
今日推荐
周排行