JS-鼠标悬停移走
2011-12-21 23:27
127 查看
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> .class1 { width:100px; height:100px; background-color:Blue; position:absolute; top:auto; left:auto; } </style> <script type="text/javascript"> var dt; function dianwo() { var mydiv = document.getElementById('mydiv'); var x = mydiv.offsetLeft; var y = mydiv.offsetTop; x += 10; y += 10; mydiv.style.left = x; mydiv.style.top = y; } function qidong() { dt = setInterval("dianwo()",100); } function stop() { clearInterval(dt); } </script> </head> <body onload="qidong();"> <div id="mydiv" class="class1" onmouseover="stop();" onmouseout="qidong();"></div> </body> </html>
实现的效果就是这样是:层自动向右下角移动,鼠标移动到层上后,停止移动,鼠标移走后,继续移动。
代码很简单,主要是逻辑别混乱了
相关文章推荐
- JS鼠标悬停时动态翻滚的紫色导航条
- 一个优秀的超链接鼠标悬停提示CSS+JS
- js-javascript-鼠标悬停弹出大图窗口的源代码
- js导航条鼠标悬停上下文字滑动
- FineReport JS实现分页预览改变鼠标悬停所在的行列的背景色
- 原生JS实现鼠标悬停图片显示文字效果
- JS特效:鼠标悬停显示提示
- 一个简单的JS鼠标悬停特效具体方法
- js实现动画特效的文字链接鼠标悬停提示的方法
- 仿youku鼠标悬停js
- CSS或者JS实现鼠标悬停显示另一元素
- JS - 6款鼠标悬停效果
- js实现文字垂直滚动和鼠标悬停效果
- js实现鼠标悬停文字上显示图片
- css效果,在一个盒子里,把一部分内容隐藏掉,在鼠标悬停到div时,就会把隐藏的部分向上显示出来。 不用js操作,纯css就可以。
- js实现鼠标悬停一定时间后触发事件--淘宝例子
- 【JS】表格行鼠标悬停背景高亮效果
- CSS+JS鼠标悬停单元格变色
- js 文字超出长度用省略号代替,鼠标悬停并以悬浮框显示
- js复制代码到其他地方+鼠标悬停显示小手