javascript get x and y coordinates on mouse click

Like this. function printMousePos(event) { document.body.textContent = “clientX: ” + event.clientX + ” – clientY: ” + event.clientY; } document.addEventListener(“click”, printMousePos); MouseEvent – MDN MouseEvent.clientX Read only The X coordinate of the mouse pointer in local (DOM content) coordinates. MouseEvent.clientY Read only The Y coordinate of the mouse pointer in local (DOM content) coordinates.