当前位置:编程学习 > JS >>

获取当前鼠标的坐标 js

<html>
<head>
<meta charset="utf-8"/>
<script>
function a(ww){
var x,y;
x=ww.clientX;
y=ww.clientY;  www.zzzyk.com
document.getElementById('div2').innerHTML="X"+":"+x+","+"Y"+":"+y;
 
}
 
</script>
</head>
<body >
<div id="div1" style="width:120px;height:120px;background-Color:'red';"  onmousemove="a(event)"></div>
<span id="div2"></span>
</body>
</html>
补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,