Differences between common programmers and awesome programmers: The pictures written by ordinary programmers fade in and fade out the codes, making full use of the order at the html level. The simplicity is amazing, and the transition effect is smoother.
The image fade-in and fade-out code written by common programmers:
Var t;
Var speed = 2; // picture switching speed
Var nowlan = 0; // image Start Time
Function changepic (){
Var imglen = $ (". newproimg"). find ("li"). length;
$ (". Newproimg"). find ("li"). hide ();
$ (". Newproimg"). find ("li"). eq (nowlan). show ();
Nowlan = nowlan + 1 = imglen? 0: nowlan + 1;
T = setTimeout ("changepic ()", speed * 1000 );
}
Onload = function () {changepic ();}
$ (Document). ready (function (){
// Hover the mouse over the image to pause Switching
$ (". Newproimg"). hover (function () {clearInterval (t );});
// Move the mouse away from the image to continue Switching
$ (". Newproimg"). mouseleave (function () {changepic ();});
});
Code for fading in and out of pictures written by coders
Var thisimg = $ (". newproimg"). find ("li ");
Var n = thisimg. length;
SetInterval (function (){
If (! Thisimg. eq (n). is (": hidden ")){
Thisimg. eq (n). fadeOut (1000)
} Else {
Thisimg. eq (n). fadeIn (3000)
}
N --;
If (n = 0 ){
N = thisimg1.length;
};
},2000 );
Makes full use of the Order of the html level. The simplicity is amazing, and the transition effect is smoother.