JQuery flop or shutter effect (automatic switch of content in three seconds)

Source: Internet
Author: User

Core code:
Copy codeThe Code is as follows:
$ (Function (){
Var timer = true; // execute the upward or downward Switch
Var liindex = 0; // LI Index
Var $ div = $ (". byc"). find ("div ");
// Change the LI content every three seconds
Var set1 = setInterval (function (){
Ainbyc ($ div );
Liindex = 0;
Timer =! Timer;
},3000 );
// LI conversion method, that is, moving the top value of the next li every 100 ms;
Function ainbyc (ds ){
Var set2 = setInterval (function (){
// After moving all LI addresses, clear them.
If (liindex = $ div. length ){
ClearInterval (set2 );
// Up
} Else if (timer ){
Ds. eq (liindex). animate ({"top": 0}, 100 );
// Downward
} Else {
Ds. eq (liindex). animate ({"top":-25}, 100 );
}
Liindex ++;
},100 );
}
})

Both the wonderful videos are clearly analyzed. Here is a summary.
1. Clear the clearInterval timer. Previously I wrote it out, and it should be written in setInterval.
2. If you are not sure what the Boolean value is, you can write: timer =! Timer;

Online Demo: http://demo.jb51.net/js/2012/mybyc/
Package download: http://www.jb51.net/jiaoben/55611.html

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.