获取鼠标移动位置

来源:互联网 发布:医美网络咨询招聘 编辑:程序博客网 时间:2024/05/21 16:45
<!doctype html><html><head><title>鼠标跟随文字</title><style type="text/css">#movefont{position:relative;}</style><script type="text/javascript">function move(event){var e=event || window.event;var obj = document.getElementById("movefont");var posX=e.clientX;var posY=e.clientY;obj.innerHTML="X:"+posX+"<br/>"+"Y:"+posY;obj.style.left=posX+10+"px";obj.style.top=posY+10+"px";}document.onmousemove=move;</script></head><body><div id="movefont"></div></body></html>

0 0
原创粉丝点击