0

为了捕获鼠标拖动事件,我尝试在鼠标按下处理程序中放置鼠标向上处理程序,因此鼠标按下后必须可以检测到鼠标向上,我计划最终将 onmousemove 移动到函数中,但我无法得到这么多工作。

正在发生的事情是它会记录越来越多的数字(至少看起来如此),而不是我试图让它记录的四个。

    var clickx;         
    var clicky;         
    var releasex;
    var releasey;
    $('#tdw-layout-editable').bind("mousedown", function(e){
      clickx=e.clientX;
      clicky=e.clientY;
      console.log(clickx + " " + clicky);
      $('#tdw-layout-editable').bind("mouseup", function(f){
         releasex = e.clientX;
         releasey = e.clientY;
         console.log(releasex + " " + releasey);
     });
    });

真的很奇怪:\谢谢

4

1 回答 1

0

改为这样做:

$(function(){
    var clickx;         
    var clicky;         
    var releasex;
    var releasey;
    $('#tdw-layout-editable').bind("mousedown", function(e){
        clickx=e.clientX;
        clicky=e.clientY;
        console.log(clickx + " " + clicky);
    }).bind("mouseup", function(f){
        releasex = f.clientX;
        releasey = f.clientY;
        console.log(releasex + " " + releasey);
    });  
 });
于 2013-01-11T01:00:28.943 回答