Leo

软件编程技术

导航

跟随鼠标移动的层

Posted on 2007-09-30 18:20  Leo(binbin)  阅读(776)  评论(0编辑  收藏  举报
<html>
    <head>
        <title>Simulated Drag And Drop Example</title>
        <script type="text/javascript">
       
            function handleMouseMove(oEvent) {
                var oDiv = document.getElementById("div1");
                oDiv.style.left = oEvent.clientX;
                oDiv.style.top = oEvent.clientY;
            }
                                 
        </script>
        <style type="text/css">
            #div1 {
                background-color: red;
                height: 100px;
                width: 100px;
                position: absolute;
            }
        </style>
    </head>
    <body onmousemove="handleMouseMove(event)">
        <p>Try moving your mouse around.</p>
        <p><div id="div1"></div> </p>
    </body>
</html>

点击这里给我发消息