JS implementation of the slide Play picture sample code _javascript Tips

Source: Internet
Author: User
1, add the following element to the page. Displays a list file of the set picture files.
Copy Code code as follows:

<select id= "Img_date" style= "width:100%; margin-top:10px; height:50% "Size=" >
<option value= "The URL of the picture" > Picture name </option>
</select>

2, the way to play the list of files. The main is to traverse the file list and show the picture in the corresponding picture container can show the effect of the slide.

The traversal method can be invoked using a delay method: Window.setinterval ("Playpics ()", speed);
Copy Code code as follows:

/**
* How to play the picture processing
* */
Function playpics ()
{
var s el = document.getElementById ("Img_date");
if (sel.length==0)//If no picture is returned directly
{
return;
}
Else
{
if (sel.selectedindex>0)//The selected subscript is greater than 0 o'clock to set the previous picture item to be selected.
{
Sel.options[sel.selectedindex-1].selected=true;
}
else{//if the subscript for the selected item is 0, set the last picture to be selected.
Sel.options[sel.length-1].selected=true;
}
Changepic (sel.options[sel.selectedindex].value);//Get the selected picture and set the URL of the picture to the appropriate picture container. The

//method can be modified to suit your needs.
}
};

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.