<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
function getXy1(event) {
var flow = document.getElementById("flow");
flow.style.left = event.clientX + 5 +"px";
flow.style.top = event.clientY + 5 + "px";
flow.innerHTML="<h6>"+event.clientX+":"+event.clientY+"</h6>";
}
</script>
</head>
//注意这里用的方法 onmousemove;body里边设置了一个样式
<body onmousemove="getXy1(event)"style="height: 1000px">
<div id="flow" style="width: 80px;height: 50px;position:absolute"></div>
</body>
</html>
时间: 2024-10-26 06:32:12