样式:

 

 js:

 

 html:

 

 1.div.onmousemove=function(e)      e 事件对象

2.获取鼠标位置

console.log(e.x,e.y)    y轴+x轴

span.style.top=e.y+"px";     y轴

span.style.left=e.x+"px";     x轴
扩展内容:
span.innerText=e.x+","+e.y;     坐标位置
posted on 2021-11-07 16:52  银小兔  阅读(49)  评论(0)    收藏  举报