層跟隨鼠標(biāo)移動(dòng)

字號(hào):


    一下代碼保存為.html運(yùn)行試試看
    <script >
    function bb()
    {
    document.getElementById("test").style.top = event.clientY + document.body.scrollTop+5;
    document.getElementById("test").style.left = event.clientX +document.body.scrollLeft+5 ;
    }
    </script>
    <body>
    <div onmousemove="bb()">
    <div id="test">aaa</div>
    </div>
    </body>