本文實(shí)例講解了基于javascript實(shí)現(xiàn)窗口抖動(dòng)效果的詳細(xì)代碼,分享給大家供大家參考,具體內(nèi)容如下
效果圖:

鼠標(biāo)點(diǎn)擊,窗口實(shí)現(xiàn)抖動(dòng)。
具體代碼:
<!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 id="bt">點(diǎn)擊振動(dòng)</button> <div id="win"></div> </body> </html>希望本文所述對(duì)大家學(xué)習(xí)javascript程序設(shè)計(jì)有所幫助,幫助大家實(shí)現(xiàn)窗口抖動(dòng)效果。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注