<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>获取鼠标位置</title>
</head>
<body>
<input id="aa"/>
<input id="bb"/>
</body>
</html>
下面两种选一种就可以了。
<script>
onmousemove = function (a) {
document.getElementById(‘aa‘).value = a.x;
document.getElementById(‘bb‘).value = a.y;
};
</script>
<script>
addEventListener("mousemove", function (a) {
document.getElementById(‘aa‘).value = a.x;
document.getElementById(‘bb‘).value = a.y;
};
</script>