问答详情
源自:4-2 [DOM事件] QQ面板拖拽效果(下)

关于光标在哪里,面板就移动到哪里这样写有问题吗?

function fndown(){

var oDrag = document.getElementById('loginPanel');

var bclientX = oDrag.offsetLeft;

var bclientY = oDrag.offsetTop; 

var aclientX = event.clientX;

var aclientY = event.clientY;

document.onmousemove = function(event){

event = event || window.event;

oDrag.style.left =  (event.clientX - aclientX + bclientX + 'px');

oDrag.style.top =  (event.clientY - aclientY + bclientY + 'px');

}

}


提问者:zrj11 2017-09-05 14:30

个回答

  • 阿叶子
    2017-09-11 21:29:03

    没问题