window.onload=drag; function drag(){ var title_box = document.getElementById('title_box'); title_box.onmousedown=fnDown; } function fnDown(event){ var oDrag = document.getElementById('title_box'), disX = event.clientX-oDrag.offsetLeft, disY = event.clientY-oDrag.offsetTop; document.onmousemove=function(event){ fnMove(event,disX,disY); } } function fnMove(event,disX,disY){ var oDrag = document.getElementById('title_box'), l = event.clientX-disX, t = event.clientY-disY; oDrag.style.left = l+'px'; oDrag.style.top = t+'px'; }
添加回答
举报
0/150
提交
取消