<!--page encoding, title, using jq-->
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<TITLE>JQ Animation </title>
<script type= "Text/javascript" src= "Js/jquery-1.11.1.js" ></script>
<script>
/* This corresponds to the record loop state of the pointer, for the following cleaning clearinterval () used by * *
var interval;
/*i is used to record the number of clicks on the "Start/Stop Animation" button, if the button clicks on the odd number of times to start the cycle, even several times to terminate the cycle/
var i = 0;
/*j is used to record the number of clicks on the "Show/Hide block Size" button, if this button hits the odd number of times to display the size, even several times to hide the size * *
var j = 0;
/* Because there is no encapsulated toggle () method, we need to do so * *
function Divanimate () {
/* Here you can only control the layer through the class value of the layer, get the symbol for the class value is. Instead of #*/
<!--requires class to be d_class layer, first to the right offset 100px, and then downward offset 100px, then left to offset 100px, and finally offset 100px back to the original position, each action within 500 milliseconds to complete, that is 0.5 seconds-->
<!--here Note that the meaning of the left is the positive direction of the X axis, the screen is 0px, the more to the right value, the top is the negative direction of the Y axis, the screen is 0px, the lower the value of the larger-->
$ (". D_class"). Animate ({left: "+=100px"}, 500);
$ (". D_class"). Animate ({top: "+=100px"}, 500);
$ (". D_class"). Animate ({left: "-=100px"}, 500);
$ (". D_class"). Animate ({top: "-=100px"}, 500);
}
function cycle () {
/* This function first executes the divanimate () function, and then executes Divanimate () once every 2000 milliseconds, that is, every 2 seconds. This interval is just the time of an animation, and without interrupting this loop, it is perfectly seamless to perform looping animations seamlessly without any gaps. */
/* The first line must exist, or each click the Start button, you have to wait 2 seconds before starting the animation * *
Divanimate ();
Interval = SetInterval ("Divanimate ()", 2000);
}
/*$ (document). Ready (function () {}) to load a Web page, the action class of all buttons must be placed in it.
$ (document). Ready (function () {
$ ("#stop"). Click (function () {
i++;
if (i% 2!= 0)
Cycle ();
Else
/* Terminate loops and the start loop above is a JavaScript function that says jquery is just an extension of JavaScript. */
Clearinterval (interval);
});
$ ("#show"). Click (function () {
j + +;
if (j% 2!= 0) {
var txt = "";
TXT + + "<p align=\" Center\ "> High:" + $ ("#d_id"). Height () + "px</br>";
TXT = = "width:" + $ ("#d_id"). Width () + "px</p>";
/* This method can output text in the corresponding component tag.
$ ("#d_id"). HTML (TXT);
} else {
var txt = "";
$ ("#d_id"). HTML (TXT);
}
});
})
</script>
I hope this article will help you with your jquery programming.