[2015-12-10]把鼠标悬停在下面的矩形上可以看到坐标-摘自别处

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        #my_div{
            height: 100px;
            width: 300px;
            border:1px solid #dddddd;
        }
    </style>
</head>
<body>
    <div id="my_div" onmousemove="mouse_on(event)" onmouseout="mouse_out()"></div>
    <div id="my_show"></div>
    <script type="text/javascript">
    function mouse_on (e) {
        x=e.clientX;
        y=e.clientY;
        document.getElementById("my_show").innerHTML = "zuobiao:"+"("+x+","+y+")";
    }
    function mouse_out () {
        document.getElementById("my_show").innerHTML = "";
    }
    </script>
</body>
</html>

 

posted @ 2015-12-10 14:56  rysly  阅读(147)  评论(0编辑  收藏  举报