Code differences between common programmers and awesome programmers

Source: Internet
Author: User
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.

 

Related Article

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.