Lottery Lucky Draw generator using JavaScript

1 min read

In this tutorial, we will be using JavaScript to generate a Lottery Lucky Draw in our webpage.

The basic idea is to rotate through a number of random numbers and and stop it at any random point to decide the winner of the lottery.

Follow this video for complete guidance :

Full Source Code for Lottery Draw Generator with JavaScript :

<style type="text/css">
    background: #3f9d43;
    width: 50%;
    margin: 0 auto;
    text-align: center;
    font-size: 12em;
      border-radius:40px 40px 0 0;
      border-bottom: 2px solid #ddd;
    font-size: 2em;
    background: #6c9dc9;
    color: #fff;
    cursor: pointer;
  .btn-winner:hover {
      transition-duration: 0.1s;
      box-shadow:  0 0 18px rgba(255, 255, 255, 0.75);
      user-select: none;


<div id="odometer" class="odometer box">0</div>
<div class="btn-winner box" onclick="getWinner();">Get Winner</div>

  <script type="text/javascript">

  function generateRandom(maxLimit = 100){
    let rand = Math.random() * maxLimit;
    rand = Math.floor(rand);
    return rand;
  function getWinner(){
    document.getElementsByClassName('btn-winner')[0].innerHTML = 'Please wait for the result ....';
    interval = setInterval(function(){
      	document.getElementById('odometer').innerHTML = generateRandom();

      document.getElementsByClassName('btn-winner')[0].innerHTML = 'Get Winner';



Recommended For You

About the Author: Admin