鼠标点击,窗口实现抖动。
具体代码:
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312"/> <title>窗口登陆效果</title> <style type="text/css"> #win { position:relative; width:100px; height:100px; background-color:#666; } </style> <script type="text/javascript"> var a=['top','left']; var b=0; var u; function fudu() { win.style[a[b%2]]=(b++)%4<2?"0px":"4px"; if(b>15) { clearInterval(u); b=0 } } function zd() { clearInterval(u); u=setInterval(fudu,32) } window.onload=function() { var bt=document.getElementById("bt"); var win=document.getElementById("win"); bt.onclick=zd; } </script> </head> <body > <button>点击振动</button> <div></div> </body> </html>