SoFunction
Updated on 2025-02-28

JavaScript-Detailed explanation of the timer 0~9 lottery system (code)

JavaScript-Detailed explanation of the timer 0~9 lottery system (code)

Updated: August 16, 2017 09:53:57 Author: bright0325
This article mainly introduces the JavaScript-timer 0~9 lottery system, and uses code examples to illustrate the overall operation of function calls. For specific steps, you can view the detailed explanation below. Interested friends can refer to it.

The specific code is as follows:

<html> 
 <head> 
  <title>Timer0~9Lottery system</title> 
  <meta charset="UTF-8" /> 
  <script type="text/javascript" src="/jquery/3.2.1/"></script> 
  <script type="text/javascript"> 
   $(function(){ 
    $("#start").click(function(){ 
     fn(); 
     timer = setInterval('fn()',200);//Fill in the DIV    }); 
    $("#stop").click(function(){ 
     clearInterval(timer);//Clear the timer    }); 
   }); 
   var i=0; 
   function fn(){ 
    $("#box").html(i); 
    i++; 
    if(i==10){ 
     i=0; 
    } 
   } 
  </script> 
 </head> 
 <body> 
  <div> 
   <button  type="button">start</button> 
   <button  type="button">stop</button> 
  </div> 
  <br /> 
  <div  style="width:200px;height:100px;border:1px solid;line-height:100px;font-size:80px;text-align:center;"></div> 
 </body> 
</html>

The above is the entire content of this article. I hope the content of this article will be of some help to everyone’s study or work. If you have any questions, you can leave a message to communicate. Thank you for your support!

  • js
  • Timer
  • lottery

Related Articles

  • Detailed explanation of how JavaScript carries cookies in cross-domain requests

    This article mainly introduces a detailed explanation of how JavaScript carries cookies in cross-domain requests. The example code is introduced in this article very detailed and has certain reference value. Interested friends can refer to it.
    2022-03-03
  • Native js realize drag and drop movement and zoom effects

    This article mainly introduces the native js to implement drag and drop movement and zoom effects. The sample code in the article is introduced in detail and has a certain reference value. Interested friends can refer to it.
    2020-08-08
  • PHP 502bad gateway reasons and solutions

    This article mainly introduces the reasons and solutions of PHP 502bad gateway. The example code is introduced in this article in detail, which has certain reference value for everyone's study or work. Friends who need it can refer to it.
    2020-11-11
  • js implements array conversion into json

    This article shares with you the code of array conversion json implemented using javascript. It is very simple and practical, equivalent to (array); for those who need it, you can refer to it.
    2015-06-06
  • Bmail contacts fly around effect

    Bmail contacts fly around effect...
    2007-01-01
  • The first example of Bootstrap and Java pagination

    This article mainly introduces the first example of Bootstrap and Java paging. It has certain reference value. Interested friends can refer to it.
    2016-12-12
  • Bootstrap confirmation button prompts the component to use detailed explanation

    This article mainly introduces in detail how to use the bootstrap confirmation button prompt component, which has certain reference value. Interested friends can refer to it.
    2017-08-08
  • Parsing JavaScript Lazy Programming from Delay Processing

    This article mainly introduces a detailed explanation of JavaScript laziness programming examples from delay processing. Friends in need can refer to it for reference. I hope it can be helpful. I wish you more progress and get promoted as soon as possible to get a salary increase as soon as possible.
    2022-10-10
  • Simple implementation of provincial and municipal selection (based on)

    Below, the editor will bring you a simple implementation of provincial and municipal choices (based on). The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look together
    2016-06-06
  • 4 ways to call functions in JavaScript

    This article mainly introduces four code examples of calling functions in JavaScript. This article gives four code examples of method calling mode, function calling mode, constructor calling mode, and apply calling mode. Friends who need it can refer to it.
    2015-07-07

Latest Comments