Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body onclick="showCoords(event)" style="border:1px solid black;padding:4px"> <h1>Mouse Events</h1> <h2>The pageX and pageY Properties</h2> <p>Click anywhere in this document to see the x and y coordinates of the mouse pointer.</p> <p id="demo"></p> <script> function showCoords(event) { let x = event.pageX; let y = event.pageY; let text = "X coords: " + x + ", Y coords: " + y; document.getElementById("demo").innerHTML = text; } </script> </body> </html>