网站制作学习网JS脚本→正文:层跟随鼠标移动
字体:

层跟随鼠标移动

JS脚本 2008/10/15 13:22:17  点击:不统计

关键词:层的移动,层跟随鼠标移动,层的坐标

一下代码保存为.html运行试试看

来自:http://www.forasp.cn

<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>

·上一篇:ajax浏览器兼容 >>    ·下一篇:js打印机滚动字 >>
推荐文章
最新文章