Source Code:
(back to article)
Submit
Result:
Report an issue
<div> <p id="mousePosition" style="height: 100px; background-color: orangered"> Hover here to track your mouse position! </p> </div> <script> document.getElementById('mousePosition').addEventListener('mousemove', function(event) { this.textContent = `Mouse Position - X: ${event.clientX}, Y: ${event.clientY}`; }); </script>