A method for implementing the effect of jquery sloshing layer _jquery

Source: Internet
Author: User

This paper illustrates the implementation of the jquery shaking layer effect. Share to everyone for your reference. The implementation methods are as follows:

Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html" charset= "Utf-8"/>
<title>jquery Shaking Layer </title>
<style type= "Text/css" >
Body {font:12px Georgia, serif;}
a {text-decoration:none;}
#header {margin:50px Auto}
#header P{text-align:center;font-size:16px;font-weight:bold}
#box {width:400px;height:200px;background-color: #ccc; Text-align:center}
</style>
<script type= "Text/javascript" src= "Js/jquery-1.6.2.min.js" ></script>
<script type= "Text/javascript" >
var box_left = 0;
$ (document). Ready (function () {
Box_left = ($ (window). Width ()-$ (' #box '). Width ())/2;
$ (' #box, #footer '). css ({' Left ': box_left, ' position ': ' absolute '});
});
Function Shock ()
{
for (i = 1; i < 7; i++)
{
$ (' #box '). Animate ({
' Left ': '-=15 '
}, 3, function () {
$ (this). Animate ({
' Left ': ' +=30 '
}, 3, function () {
$ (this). Animate ({
' Left ': '-=15 '
}, 3, function () {
$ (this). Animate ({
' Left ': box_left
}, 3, function () {
Shock End
});
});
});
});
}
}
</script>
<body>
<div id= "Header" >
<p> Imitation WP Background login error when left or right shaking a layer </p>
</div>
<div id= "box" ><a href= "#" onclick= "shock (); return false;" > Click me to view Effects </a></div>
</body>

I hope this article will help you with your jquery programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.