JSFiddle - React, Tailwind, and code Playground
HTML
<div id="d">
</div>
<div id="cordinates"></div>
CSS
#d
{
background-color:green;
width:200px;
height:200px;
}
JavaScript
function printMousePos(e) {
var cursorX = e.clientX;
var cursorY = e.clientY;
document.getElementById('cordinates').innerHTML = "X: " + cursorX + " Y: " + cursorY;
}
document.getElementById("d").addEventListener("mousemove", printMousePos);