xxxxxx <script><br> function shake(e, onComplete, distance, interval)<br> {<br> if (typeof e === "string")<br> {<br> e = document.getElementById(e);<br> } // end if<br> distance = distance || 8;<br> interval = interval || 800;</p>
<p> var originalStyle = e.style.cssText;<br> e.style.position = "relative";<br> var start = (new Date()).getTime();</p>
<p> animate();</p>
<p> function animate()<br> {<br> var now = (new Date()).getTime();<br> var elapsed = now - start;<br> var progress = elapsed / interval;<br> if (progress < 1)<BR> {<BR> var y = distance * Math.sin(Math.PI * progress * 4);<BR> var x = distance * Math.cos(Math.PI * progress * 4);<BR> e.style.left = x "px";<BR> e.style.top = y "px";<BR> console.log(e.style.cssText);<BR> setTimeout(animate, Math.min(25, elapsed));<BR> } // end if<BR> else<BR> {<BR> e.style.cssText = originalStyle;<BR> if (onComplete)<BR> {<BR> onComplete(e);<BR> } // end if</P>
<P> } // end else</P>
<P> } // end animate()</P>
<P> } // end shake()</P>
<P> </script>