Jquery random lottery Effects

Source: Internet
Author: User

Jquery random lottery Effects

Introduction: The jQuery custom value lottery activity code is a computer that clicks the start button to generate a random number within the range of player input. Click the stop button to display the final result of the number.

Effect display http://hovertree.com/texiao/jquery/76/

As follows:


The Code is as follows:

1 <! DOCTYPE html> 2 

The js File Code is as follows:

1/** 2 * why does the Created by ask about the afternoon sun on. 3 */4 var ran = 0; 5 var range = 0; 6 var myNumber; 7/* encapsulate the method that generates random numbers */8 function sjs (range) {9 ran = Math. random () * range; // random Number of [0, range) 10 var result = parseInt (ran); // converts a number to an integer 11 return result; 12} 13/* encapsulate the method for displaying random numbers */14 function showRandomNum () {15 var figure = sjs (range ); 16 $ ("# first" example .html (figure); 17 var figure2 = sjs (range); 18 $ ("# second" example .html (figure2 ); 19 var figure3 = sjs (range); 20 $ ("# third" ).html (figure3); 21} 22 $ (function () {23/* click Start, events generated */24 $ ("# start "). click (function () {25 26 range = prompt ("Enter the random number range:", "168"); 27 28 if (range = null )// http://hovertree.com/h/bjaf/3siyd3x7.htm29 {30 return; 31} 32 33 if (range = 0) 34 {35 return; 36} 37 38 if (isNaN (range ))// http://hovertree.com/h/bjaf/9vhm2l4f.htm39 {40 alert ("enter a number"); 41 return; 42} 43/* disable the start label and disable the label */44 $ ("# start ") [0]. disabled = true; 45 $ ("# stop") [0]. disabled = false; 46 if (range> 9999 | range <-999) 47 {48 // by 49 49 $ ("# bigDiv div" ).css ("font-size", "60px ");// http://hovertree.com/h/bjaf/omgdn4mu.htm50 // Return; 51} 52 myNumber = setInterval (showRandomNum, 50); // how long it takes to run, in milliseconds 53 }); 54/* click the end button */55 $ ("# stop "). click (function () {56/* to enable the label. Disable the label. */57 $ ("# start") [0]. disabled = false; 58 $ ("# stop") [0]. disabled = true; 59 clearInterval (myNumber); 60}); 61 });

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.