相对简单易懂的div拖动代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> 拖动 </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="robin.c">
  </head>

<script>   
function $(ID){   
 return document.getElementById(ID);   
}   
var v=0;   
var x,y;   
function getV(s){   
 v=s;   
 x=event.clientX-$("aryee").style.pixelLeft;   
 y=event.clientY-$("aryee").style.pixelTop;   
}   
function dragit(ID){   
 if(v==0){   
 return false;   
 }else{   
 $(ID).style.pixelLeft=event.clientX-x;   
 $(ID).style.pixelTop=event.clientY-y;   
 }   
}   
</script>   
<body >   
<div style="background:#CCC;width:100px;height:100px;position:absolute;"
id="aryee" </div>   
</body> 
</html>

你可能感兴趣的:(职场,拖动,div,休闲)