Js Implementation of Slide playback image example code _ javascript skills

Source: Internet
Author: User
You may have seen the effect of the slide picture. Here is a good example. If you are interested, refer to section 1 and add the following elements on the page. Displays the output and output image file list.

The Code is as follows:


Image name


2. Playback file list method. The main function is to traverse the file list and display the image in the corresponding image container to show the effect of the slide.

You can use the latency method to call the Traversal method: window. setInterval ("PlayPics ()", speed );

The Code is as follows:


/**
* Method of processing the playback Image
**/
Function PlayPics ()
{
Var sel = document. getElementById ("img_date ");
If (sel. length = 0) // return directly if no image is available
{
Return;
}
Else
{
If (sel. selectedIndex> 0) // when the subscript of the selected image is greater than 0, the item is selected.
{
Sel. options [sel. selectedIndex-1]. selected = true;
}
Else {// If the subscript of the selected item is 0, set the last image to be selected.
Sel. options [sel. length-1]. selected = true;
}
ChangePic (sel. options [sel. selectedIndex]. value); // obtain the selected image and set the image url to the corresponding image container.

// This method can be modified as needed.
}
};

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.