javascript onmousemove get relative coordinates
13,746
The above example using guide.offsetLeft only works if the enclosing element is at (0,0). If not, you can use guide.getBoundingClientRect().left (and similar for vertical coord)
Author by
Admin
Updated on June 05, 2022Comments
-
Admin almost 2 years
function aim() { var mousex = ? } <div class="gameArea" onmousemove="aim();"> </div>
I can't find how to get the mouse coordinates for an onmousemove event in javascript.