Example of a javascript lucky draw _ javascript skills

Source: Internet
Author: User
This article mainly introduces the special effects of the javascript lantern draw, which has some reference value. if you are interested, you can refer to the examples in this article to explain the special effects of the javascript lantern draw, which is especially suitable for lottery activities, the content is as follows:

 Lottery gamesScript window. onload = init; var setting = {count: 0, total: 24, delay: 20, picIndex: [0, 1, 2, 4, 7, 6, 5, 3]} function init () {document. getElementById ("drawBtn "). onclick = function () {setting. count = 0; setting. delay = 20; this. disable = true; // disable the button var drawBtn = this; // Obtain the p var allDivs = document for all images. getElementsByClassName ("pic"); // Obtain a random integer that represents the winning position, 3*8 + (0-7) setting. total + = Math. floor (Math. random () * allDivs. length); // Set the timer to change the color of each p border in sequence. setTimeout (function show () {// reset the color of the last border for (var I = 0; isetting. total) {alert ("You have won, haha"); drawBtn. disable = false; return;} setTimeout (show, setting. delay) ;}, setting. delay) ;}} script

1

2

3

4

5

6

7

8

The above is the detailed content of this article, hoping to help you learn.

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.