Skillfully use array to make picture switch JS code _javascript skill

Source: Internet
Author: User
Tags prev

In the previous article, we talked about the specific operation of JS array, see (JS to the array of various operations summary), here will no longer do a detailed explanation. The main purpose today is to use the array to make a simple switch around the picture.

The picture transitions in this article are specific steps:

The 1th step: simple layout and design basic display style;
2nd step: Through JS to obtain relevant elements;
3rd step: Through the array of image URL and corresponding text description of the storage;
The 4th step: initialization: Including the initialization of the picture, showing the image number and corresponding to the initialization of the text;
5th step: Click the button to switch pictures, write the corresponding function, in fact, is the simple array of applications.
Next, take a look at the effect map, and then explain the corresponding code.

Implementation code:

<! DOCTYPE html>

This example is very simple, the main is the simple reading and writing of the array and the content of HTML attributes read and write operations. It should be noted that when we click on the next to the last picture or click on the previous one to the first, you need to set specific numerical changes, not = Otherwise will cross, then the picture, number and the corresponding problem is not content.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.