标签:UNC win doc down oev var div 菜鸟 bsp
这是第一次发博,博主属于菜鸟系列,如果有不对的地方欢迎指教,直接分享实例,非常好用,不过要注意各个div的z-index属性
1 //拖动 “需要给id=show的div加上绝对定位position:absolute;” 2 window.onload = function() 3 { 4 var div1 = document.getElementById("show"); 5 div1.onmousedown = function(ev){ 6 var oevent = ev || event; 7 var distanceX = oevent.clientX - div1.offsetLeft; 8 var distanceY = oevent.clientY - div1.offsetTop; 9 10 document.onmousemove = function(ev){ 11 var oevent = ev || event; 12 div1.style.left = oevent.clientX - distanceX + ‘px‘; 13 div1.style.top = oevent.clientY - distanceY + ‘px‘; 14 } 15 document.onmouseup = function(){ 16 document.onmousemove = null; 17 document.onmouseup = null; 18 } 19 } 20 }
标签:UNC win doc down oev var div 菜鸟 bsp
原文地址:https://www.cnblogs.com/huohuadidi/p/9640557.html