js实时显示鼠标坐标

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>鼠标坐标随时变动</title>
</head>
<body>
<div id="event"></div>
<script type="text/javascript">
    var id = document.getElementById('event');
    document.addEventListener('mousemove',function(e){
        id.style.marginLeft = e.clientX + 'px';
        id.style.marginTop = e.clientY + 'px';
        id.innerHTML = "(X:" + e.clientX+",Y:"+e.clientY+ ")";
    });
</script>
</body>
</html>

上一篇:图解Js event对象offsetX, clientX, pageX, screenX, layerX, x区别


下一篇:selenium---常用判断元素方法(expected_conditions)