<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#top_div{
position:absolute;
width:100PX;
height:50px;
border:1px solid #00F;
text-align:center;
color:blue;
}
</style>
<script type="text/javascript" src="jquery/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
function initMouseMove(){
document.onmousemove = function (e){
x = document.documentElement.scrollLeft+e.clientX;
y = document.documentElement.scrollTop+e.clientY;
$("#top_div").html("当前坐标 X:"+x+"Y:"+y);
$("#top_div").css("left",x);
$("#top_div").css("top",y);
}}
</script>
</head>
<body onload="initMouseMove()">
<div id="top_div"></div>
</body>
</html>
获取鼠标实时坐标
最新推荐文章于 2025-03-25 17:10:12 发布