为了账号安全,请及时绑定邮箱和手机立即绑定

onmousedown 和onmouseup应该在哪一段代码中写?

看程序中,   oTitle.onmousedown=fnDown;  是作用在login_logo_webqq这个DIV的, 按道理, 那么onmouseup也应该是作用在这个地方,为什么下面document.onmouseup是作用在document里面的事件?  按道理, onmousedown和onmouseup是不是应该写在一个函数里面的? 因为不可能一直是onmousedown的状态啊

function drag()  {

    var oTitle=getclass("login_logo_webqq","loginPanel")[0];

    oTitle.onmousedown=fnDown;

}


function fnDown(event){

    event=event||window.event;

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

     disX=event.clientX-oDrag.offsetLeft,

     disY=event.clientY-oDrag.offsetTop;

      document.onmousemove=function(event) { 

        event=event||window.event;

        fnMove(event,disX,disY); 

      }


       document.onmouseup=function() {document.onmousemove=null;

       document.onmouseup=null;

       }

}


正在回答

1 回答

我看看试了课题里的代码,把document改成otitle,效果实现的是一样的,用document的话,可以不用再取一下那个otitle这变量,减少代码的量。

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

onmousedown 和onmouseup应该在哪一段代码中写?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号