JavaScript implementation of class random naming small application requirements of the specific analysis _javascript skills

Source: Internet
Author: User
Requirements are as follows:

1. Show the names of all the people in the class on the Web page.

2. Click the Start button, the person's color began to change, when the stop, there will be a different color position, then this position is to be point to the classmate.

The approximate graphical interface is as follows:



The following is a detailed analysis of the above requirements analysis as follows:

1. Initialize such a page and set the uniform color-green.

A. The name of the classmate, stored with an array

B. Display with Div block on page

2. Randomly choose a position to change its color into-red

A. Color changes with CSS style to control

B. Random location using random function to generate

3. In order for it to have the effect of animation, set the interval time to change the position of the color to move backwards. and restore the color of the previous position to green.

A. Need to design a method to let the div color change, while moving backwards should call a time interval call method, then JS has Settimeout,setinterval method to choose to use

4. The effect of the animation, should be stopped within the specified time, the stop position is still red.

A. The animation effect stops within a specified time, in effect stopping the above method. Using different methods in JS, there are different forms of implementation

5. When stopped at a certain location, pop up a dialog box showing who is the selected student.

The A.alert function pops up and the final result is OK.

In the next section, you will implement the JavaScript code for this small application Oh.
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.