層跟隨鼠標(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 style=height:1000px; width:1000px; background:#ff0000; onmousemove=bb()>
    <div id=test style= position:absolute;left:100px; top:110px; background-color:#cccccc; width:100px; height:100px;>aaa</div>
    </div>
    </body>