Very simple JS switching effect (with extrapolate effect)

Source: Internet
Author: User

Today inadvertently found on the Internet, the code is very simple, a look at the JS image switching effect code, like simple friends can refer to.

Html:

1 <  src= "A1.jpg"  width= "478"  height= "286"  ID = "Showpic" />

The picture can be set by itself, let's take a look at the switch script, and use an array to load the picture together.

1 <Scripttype= "Text/javascript">2 window.onload= function(){    3     varCurindex= 0;4     varTimerInterval=  -; //time interval unit milliseconds5     vararr= NewArray ();6 arr[0] = "a1.jpg";7 arr[1] = "a2.jpg";8 arr[2] = "a3.jpg";9 arr[3] = "a4.jpg";Ten arr[4] = "a5.jpg"; One arr[5] = "a6.jpg"; A arr[6] = "a6.jpg"; - setinterval (changeimg,timerinterval); -     functionchangeimg () { the         varobj=document.getElementById ('Showpic'); -         if(Curindex==Arr.length- 1){ - Curindex= 0; -         }Else{ + Curindex+= 1; -         } + obj.src=Arr[curindex]; A     } at } - </Script>    

This piece of code is simple but ingenious.

After testing, automatic switching can be achieved completely.

Very simple JS switching effect (with extrapolate effect)

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.