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