首页 > 网站 > WEB开发 > 正文

js抖动

2024-04-27 14:20:34
字体:
来源:转载
供稿:网友

js抖动

效果

demo image dithering effect

代码

1234567891011<img src="http://s1.vevb.com/20150728/ksnu2b0kcol36.jpg" onMouSEOver="shake(this,'onmouseout')" ><script type="text/javascript">var typ = ["marginTop","marginLeft"],rangeN=10,timeout=20;function shake(o,end){var range=Math.floor(Math.random()*rangeN);var typN=Math.floor(Math.random()*typ.length);o["style"][typ[typN]]=""+range+"px";var shakeTimer=setTimeout(function(){shake(o,end)},timeout);o[end]=function(){clearTimeout(shakeTimer)};}</script>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表