I have a function in javascript that moves one div depending on the mouse position. This function is set on a setInterval() function and executed every second. I need to capture the mouse position like this:
function mousemov() {
document.getElementById("myDiv").style.left = Event.clientX; //don't work
}
window.onload = function() {
setInterval("mousemov()",1000);
}
Ps: I cannot use the mousemove event because the function must be executed even if the mouse is stopped.
Thanks for helps!
divif the mouse is not moving. Update the coordinates only on mousemove. - IonuČ› G. Stan