js 获取鼠标位置的两种方法
<!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>
js 获取鼠标位置的两种方法
原文:https://www.cnblogs.com/lgxblogs/p/15270413.html