js_干练拖拽__工作中可直接引用
<!DOCTYPE HTML><html><head> <meta http-equiv="content-type" charset="utf-8" /> <meta http-equiv="content-type" content="text/html" /> <title>demo__拖拽</title></head><body><p>aaaaaaaaaaa</p><div id="one" ></div><script>var odiv=document.getElementById("one");
dra(odiv);function dra(obj){ obj.onmousedown=function(e){ var oe=e||window.event; var $this=this; var l=oe.clientX-$this.offsetLeft; var t=oe.clientY-$this.offsetTop; document.onmousemove=function(e){ var oe=e||window.event; $this.style.left=oe.clientX-l+"px"; $this.style.top=oe.clientY-t+"px"; } document.onmouseup=function(){ document.onmousemove=null; document.onmouseup=null; if($this.releaseCapture){ $this.releaseCapture(); } } if($this.setCapture){ $this.setCapture(); } return false; }}</script></body></html>
TAG: