<!DOCTYPE html>
<html>
<head>
<style>
div {
position: fixed;
top: 10px;
left: 10px;
padding: 10px;
background-color: #f1f1f1;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<div></div>
<script>
const d = document.querySelector('div')
document.addEventListener('mousemove', function (e) {
let x = e.clientX
let y = e.clientY
d.innerHTML = `X: ${x}, Y: ${y}`
})
</script>
</body>
</html>
标签:浏览器,鼠标,let,坐标,10px,div,document
From: https://www.cnblogs.com/bangbangzoutianya/p/17635716.html