So I am trying to make script when u press for example "1" then click mouse to send position of cursor, but i have problems with global variables and functions namely with mX
and mY
$('#A').on("mousemove", function (e) { mX = e.pageX });
$('#A').on("mousemove", function (e) { mY = e.pageY });
...
else if (code == 49) {f(vX, vY, mX, mY);}
...
function f(vX, vY, mX, mY) {
$('#A').click(function (e) {
var dX = Math.abs(vX - mX); <<< Here is the problem the mX is not defined
var dY = Math.abs(vY - mY);
});
The problem line i singed as <<<
i can't come with up how to solve it, i have make the variables in function to global.
Do not pay attention about code
, vX
, vY
theese variables are working fine!