YouTube Icon

How to Create A Countdown Timer with Progress Bar in JavaScript

How to Create A Countdown Timer with Progress Bar in JavaScript

In this instructional exercise, I am will demonstrate to you proper methodologies to make a commencement in JavaScript with advancement bar. Here we going to make a Progress bar with a characterized max esteem and beginning quality instated with zero. 

At that point we will make a commencement. While running the commencement our advancement bar will get stacked with time. 

With the end goal to make this advancement bar commencement or switch stopwatch, we have to complete a few things. 

Also Read:- How to Build a Chrome Extension in JavaScript

As a matter of first importance, we need to make an advancement bar. How about we do it. 

<progress value="0" max="10" id="pbar" ></progress> 

Here esteem is relegated with zero since we need to begin the advancement bar counter with zero. 

Max esteem is here 10. The advancement bar begins with zero and can go up to 10. 

Presently we require a zone to print the commencement. Here we will give a case of a 10 to 0 commencement in JavaScript. ( ten to zero commencement in JavaScript ). So simply make a "p" territory to print the commencement. 

<p id="counting">10</p> 

In this p label territory, we going to print 10 and afterward 9 and 8 et cetera. That implies a commencement like 10 9 8 7 6 5 4 3 2 1 0 

Also Read:- How to count the occurrence / frequency of array elements in JavaScript

You may likewise get interset in, 

Base Sticky Music Player Source Code in JavaScript and CSS 

Alarm Before Leaving A Web Page Using JavaScript jQuery 

Commencement in JavaScript with Progress Bar – Reverse stopwatch 

The underneath is the JavaScript Code 

<script type="text/javascript"> 

var reverse_counter = 10; 

var downloadTimer = setInterval(function(){ 

document.getElementById("pbar").value = 10 - reverse_counter; 

if(reverse_counter <= 0) 


document.getElementById("counting").innerHTML= reverse_counter; 



We have utilized setInterval capacity to call a capacity at indicated interims. 

1000 is our interim time in milliseconds or we can state it as a one-moment interim. 

Also Read:- What is difference between Node.JS and Express.JS?

As it is a commencement of 10 seconds in this precedent so advance bar max incentive to be 10 and interim to be 1 seconds. In this manner 10/1= 10, You can either set the advancement bar max incentive to 100 and interim to be 100 milliseconds. The outcome will be the equivalent yet the thing that matters is that for this situation, the commencement will be from 100 to 0 and an opportunity to execute the commencement will be 10 seconds. 

I will propose you to change the estimations of interim time and advancement bar max incentive to perceive how this is functioning. It will assist you with understanding effortlessly. 

Advancement ban Countdown from 10 to 0 utilizing catch onclick in JavaScript 

The underneath is the case of the basic commencement with onclick catch. Simply test it on your program and adjust according to your desire to have some good times. 

Also Read:- Most important metrics you aren’t measuring: User Experience Design

Here is the full code. 

<!DOCTYPE html>
  <progress value="0" max="10" id="pbar" ></progress><p id="counting">10</p>
  <button id="start" onclick="start_countdown()">Start CountDown</button>
  <script type="text/javascript">
    function start_countdown(){
    var reverse_counter = 10;
var downloadTimer = setInterval(function(){
  document.getElementById("pbar").value = 10 - --reverse_counter;
  if(reverse_counter <= 0)
  document.getElementById("counting").innerHTML= reverse_counter;

Also Read:- What is the difference between Unix and Linux operating system?

Also Read:- How to build Snake using only JavaScript, HTML & CSS: Think like a Developer

Author Biography.


CrowdforThink is the leading Indian media platform, known for its end-to-end coverage of the Indian startups through news, reports, technology and inspiring stories of startup founders, entrepreneurs, investors, influencers and analysis of the startup eco-system, mobile app developers and more dedicated to promote the startup ecosystem.

Join Our Newsletter.

Subscribe to CrowdforThink newsletter to get daily update directly deliver into your inbox.

CrowdforGeeks is where lifelong learners come to learn the skills they need, to land the jobs they want, to build the lives they deserve.


CrowdforThink is a leading Indian media and information platform, known for its end-to-end coverage of the Indian startup ecosystem.


Our mission is "Har Koi Dekhe Video, Har Ghar Dekhe Video, Ghar Ghar Dekhe Video" so we Provide videos related to Tutorials, Travel, Technology, Wedding, Cooking, Dance, Festivals, Celebration.

Apna Video Wala

News & Blogs


An In-Depth Guide On Choosing Best Frontend Fra...

Since the outbreak of COVID-19, business operations have been moved online to make ends meet....


What is the Difference Between =, ==, and === i...

What is = in JS?  Equivalent to (=) is a task administrator, which sets the variable on t...


JavaScript Mobile Frameworks worth considering ...

When it comes to startups entering the business arena, they have very tough competition. This is ...

Top Authors

Lamia Rochdi is the Marketing Manager at Bell Flavors & Fragrances EMEA. A successful family-...

Lamia Rochdi

I’m Mertin Wilson a technician in a camera company and certified expert of different P...

Mertin Wilson

Zakariya has recently joined the PakWheels team as a Content Marketing Executive, shortly after g...

Zakariya Usman

Pankaj Singh is a Senior Digital Marketing Consultant with more than 2 years of experience in SEO...

Pankaj Singh

Our Client Says

WhatsApp Chat with Our Support Team