Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Strict // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> jquery window vibration effect </title>
<Script type = "text/javascript" src = "http://www.codefans.net/ajaxjs/jquery-1.6.2.min.js"> </script>
<Script type = "text/javascript">
; (Function ($ ){
Var element = {};
$. Fn. jshaker = function (){
Element = $ (this );
Element.css ('position', 'relative ');
Element. find ('*'). each (function (I, el ){
Vertex (elast.css ('position', 'relative ');
});
Var iFunc = function () {$. fn. jshaker. animate ($ (element ));};
SetTimeout (iFunc, 50 );
};
$. Fn. jshaker. animate = function (el ){
$. Fn. jshaker. shake (el );
El. find ('*'). each (function (I, el ){
$. Fn. jshaker. shake (el );
});
Var iFunc = function () {$. fn. jshaker. animate (el );};
SetTimeout (iFunc, 50 );
}
$. Fn. jshaker. shake = function (el ){
Var pos = $ (el). position ();
If (Math. random () & gt; 0.5 ){
Vertex (eldomain.css ('top', pos ['top'] + Math. random () * 20 <10? (Math. random () * 20 * (-1): Math. random () * 20 );
} Else {
Vertex (el).css ('left', pos ['left'] + Math. random () * 20 <10? (Math. random () * 20 * (-1): Math. random () * 20 );
}
}
}) (JQuery );
</Script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ('. Block'). click (function (){
$ (This). jshaker ();
});
});
</Script>
<Style type = "text/css">
BODY {font-family: "Lucida Grande", Arial, Helvetica, sans-serif; color: #666666; font-size: 12px; background: # FFFFFF ;}
A {color: # 0A8ECC ;}
A: HOVER {text-decoration: none; color: # 8FCB2F ;}
H1 {font-weight: normal; color: # 0A8ECC; margin: 0; padding: 0 ;}
BODY {margin: 20px; padding: 20px ;}
STRONG {color: #000000 ;}
. Vspacer {height: 20px ;}
PRE. code {padding: 7px; background: #777777; color: # F0F0F0; width: 400px; overflow: auto ;}
# Content-area {border: 3px solid # CCCCCC; background: # F0F0F0; padding: 10px; width: 500px ;}
P. script-link {clear: both; padding: 10px 0; border-top: 1px dotted # CCCCCC ;}
# Content. block {float: left; border: 1px solid # CCCCCC; background: # F0F0F0; padding: 10px; margin: 10px; width: 300px ;}
</Style>
</Head>
<Body>
<Div id = "page">
<H1> jquery window interface vibration special effect <Div id = "content">
<Div class = "block">
<P> click in this box to vibrate </p>
<Ul>
<Li> Item 1 </li>
<Li> Item 2 </li>
<Li>
Item 3
<Ul>
<Li> Sub Item 1 </li>
<Li> Sub Item 2 </li>
<Li> Sub Item 3 </li>
<Li> Sub Item 4 </li>
<Li> Sub Item 5 </li>
</Ul>
</Li>
<Li> Item 4 </li>
<Li> Item 5 </li>
</Ul>
</Div>
<Div class = "block">
<Form action = "#">
<P> <label for = "inp1"> Text Field 1: </label> <input type = "text" name = "inp1" id = "inp1" value = ""/> </p>
<P> <label for = "inp2"> Text Field 2: </label> <input type = "text" name = "inp2" id = "inp2" value = ""/> </p>
<P> <button type = "submit"> Submit </button> </p>
</Form>
</Div>
</Div>
<P class = "script-link">
</P>
</Div>
</Body>
</Html>