Switching of images simply made using JS

Source: Internet
Author: User

Switching of images simply made using JS

When you do a webpage, you need to use JS to display images with special effects. The following describes how to switch images that are made using JS.

When creating a web page, you need to use JS to display images with special effects. Below is a simple switching of images made using JS.

The Code is as follows:

<Html>

 

<Head>

 

<Script type = "JavaScript">

 

Var srr = new Array ('image 1', 'image 2', 'image 3', and 'image 4'); // store data using the built-in Array in JS

Var s = 0;

Function chage (){

Var img = document. getElementById ('img1 ');

If (s <srr. length-1 ){

S ++;

}

Else {

S = 0;

}

Img. setAttribute ('src', srr [s]);

}

Function diaoyong (){

SetInterval (chage, 1000 );

}

 

</Script>

 

</Head>

 

<Body onLoad = "diaoyong ();">

 

</Body>

 

</Html>

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.