要捕获鼠标拖动事件,我尝试在鼠标按下处理程序中放置一个鼠标处理程序,因此鼠标按下后必须能够检测到鼠标,我计划最终将一个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);
});
});
真奇怪: 谢谢
答案 0 :(得分: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);
});
});