<div id="mouse"></div>
#mouse {
width: 100%;
height: 200px;
background-color: #f60;
text-align: center;
font-size: 2em;
}
document.querySelector("#mouse").addEventListener("mousemove", (event) => {
event.target.textContent =
`position: ${event.offsetX}x, ${event.offsetY}y`;
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.