<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript层抖动效果</title>
<style type="text/css">
#body{text-align:center;}
#test{width:200px;position:absolute;margin:10px auto;height:100px;border:2px dotted red;text-align:center}
</style>
</head>
<body>
<div style="margin:10px 200px">
<div>
<input type="button" value="~点这里让我抖抖吧~" onclick="nn.start()" /></div>
<div>
<input type="button" value="晃晕了,我不抖了!" onclick="nn.stop()" /></div>
<div id="test">
<br>
</div>
</div>
<p> </p>
<p> </p>
</body>
</html>
<script type="text/javascript">
var m=document.getElementById("test");
function SKclass (obj,Rate,speed) {
var oL=obj.offsetLeft;
var oT=obj.offsetTop;
this.stop=null;
this.oTime=null;
var om=this;
this.start=function(){
if(parseInt(obj.style.left)==oL-2){
obj.style.top=oT+2+"px";
setTimeout(function(){obj.style.left=oL+2+"px"},Rate)
}
else{
obj.style.top=oT-2+"px";
setTimeout(function(){obj.style.left=oL-2+"px"},Rate)
}
this.oTime=setTimeout(function(){om.start()},speed);
}
this.stop=function(){
clearTimeout(this.oTime); }
}
var nn=new SKclass(m,20,70);
</script>
</body>
</html>

最新文章

  1. [原][C#][winForm]分级基金折溢价WinForm网络计算器
  2. 定时器中实现数据库表数据移动的功能,Exception in thread &quot;Timer-0&quot; isExist java.lang.NullPointerException定时器中线程报错。
  3. GitHub学习心得之 安装配置与多帐号管理
  4. 纯window下VMware 安装 OS X El Capitan 原版映像【未完待续】
  5. html特殊字符转义问题(转!)
  6. inotify-tools使用方法介绍
  7. SpringMvc_@RequestMapping设置Router Url大小写不敏感
  8. oracle插入主键数据、sequence和触发器
  9. iptables学习笔记
  10. PKU 1511 Invitation Cards (SPFA+邻接表)
  11. Mapreuduce实现网络数据包的清洗工作
  12. 19 款仿 Bootstrap 后台管理主题免费下载
  13. Spring Cloud 组件 —— feign
  14. mybatis框架(3)---SqlMapConfig.xml解析
  15. 【转】宽带路由器应用(三)—ARP欺骗防护功能的使用
  16. Git分支合并:Merge、Rebase的选择
  17. 校内模拟赛 虫洞(by NiroBC)
  18. 在linux环境下,php语法出错,怎样让php编译后提示编译错误,错误在哪?
  19. Bootstrap 样式设计 栅格系统
  20. Android Webservices 返回多行多列数据(Dataset)

热门文章

  1. 利用PinYin4j 实现List中的对象按数字,字母, 汉字排序
  2. ViewPager 基本方式加载view
  3. 高质量JavaScript代码书写基本要点
  4. 【CDN】国外访问国内服务器网站-响应慢-CDN
  5. CSS3_新特性预览
  6. 小韦系统装工行网银U盾驱动的方法
  7. MySQL for Windows 解压缩版配置安装
  8. div contenteditable placeholder
  9. 34-Ajax辅助方法
  10. [backbone]backbone.js