Hello. Help pass the coordinates of the cursor from the mouseMove function, the curx, cury variables that are globally declared do not change the values in the function. Rather, it turns out that the function declares the local variables curx, cury, and their values can be used only inside the function.
function createImage() { var canvas = document.getElementById("Canvas"); var ctx = canvas.getContext("2d"); var curx; var cury; canvas.onmousemove = mouseMove; function mouseMove(event){ curx=event.pageX-8; cury=event.pageY-8; } document.getElementById('mouseX').value=curx; document.getElementById('mouseY').value=cury; }
var curx;
/var cury;
? - xEdelweisscreateImage()
function, in which document.getElementById ('mouseX') occurs. value = curx; document.getElementById ('mouseY'). value = cury; call once and whenmouseMove
ismouseMove
this part of the code is not executed, use the answer @Photon - Specter