<div id="mouse" style="width:300px;height:100px;border:1px solid #ccc"></div>
<div id="out"></div>
<script type="text/javascript">
var mouses = document.getElementById("mouse");
mouses.onmousemove = function(m){
var x = m.clientX;
var y = m.clientY;
document.getElementById("out").innerHTML = "坐标:("+x+","+y+")";
}
mouses.onmouseout = function(){
document.getElementById("out").innerHTML = "";
}
</script>
时间: 2024-10-07 09:39:43