offsetLeft : 返回当前元素的相对水平偏移位置的偏移容器
offsetTop : 返回当前元素的相对垂直偏移位置的偏移容器
相对浏览器的边缘大小
比如是margin-top为15px 那么offsetTop就为15px
只有上和左
pageX :当前指针所在的X位置
pageY :当前指针所在的Y位置
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document).mousemove(function(e){
$("span").text("X: " + e.pageX + ", Y: " + e.pageY);
});
});
</script>
</head>
<body>
<p>鼠标指针位于: <span></span></p>
</body>
</html>
clientX 事件属性返回当事件被触发时鼠标指针相对于浏览器页面(或客户区)的水平坐标。
客户区指的是当前窗口。
event.clientX