Creating Progress Bar using JavaScript Last Updated : 27 Jun, 2024 Comments Improve Suggest changes Like Article Like Report A Progress Bar is used to depict the progress of any task which is being carried out. Progress Bars are generally used to show the download and upload status. In other words, we can say that Progress Bars can be used to depict the status of anything that is in progress. There are several approaches to creating a progress bar using JavaScript.Table of ContentUpdating the Width of an HTML ElementUsing HTML5 progress ElementUsing JavaScriptUpdating the Width of an HTML ElementIt Update the width of a <div> element dynamically to represent progress.Example: To demonstrate creating a progress bar by updating the width of an HTML element. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Progress Bar Example - Approach 3</title> <style> .progress-bar { width: 100%; background-color: #f0f0f0; height: 30px; margin-bottom: 10px; } .progress { width: 0%; height: 100%; background-color: #4caf50; transition: width 0.3s ease; } </style> </head> <body> <h2>Progress Bar - Approach 3</h2> <div class="progress-bar"> <div id="progress" class="progress"></div> </div> <button onclick="increaseProgress()">Increase Progress</button> <button onclick="resetProgress()">Reset</button> <script> const progressBar = document .getElementById('progress'); let currentProgress = 0; function increaseProgress() { if (currentProgress < 100) { currentProgress += 10; progressBar .style .width = currentProgress + '%'; } } function resetProgress() { currentProgress = 0; progressBar.style.width = '0%'; } </script> </body> </html> Output:OutputUsing HTML5 progress ElementOne can use the <progress> element in HTML5 to represent progress in the progress bar. Which has built-in support for displaying and updating progress.Example: To demonstrate creating progress bar using HTML5 <progress> element. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Progress Bar Example - Approach 2</title> </head> <body> <h2>Progress Bar - Approach 2</h2> <progress id="progress" value="0" max="100"></progress> <button onclick="increaseProgress()">Increase Progress</button> <button onclick="resetProgress()">Reset</button> <script> const progressElement = document .getElementById("progress"); function increaseProgress() { if (progressElement.value < 100) { progressElement.value += 10; } } function resetProgress() { progressElement.value = 0; } </script> </body> </html> Output:OutputUsing JavaScriptOne can customize the JavaScript to update a visual representation of progress. Example: To demonstrate creating progress bar using JavaScript. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Progress Bar Example</title> <style> .progress-bar { width: 500px; background-color: #f0f0f0; height: 30px; margin-bottom: 10px; border-radius: 15px; } .progress { width: 0px; height: 100%; background-color: #4caf50; transition: width 0.3s ease; } </style> </head> <body> <h2>Progress Bar</h2> <div class="progress-bar"> <div id="progress" class="progress"></div> </div> <button onclick="increaseProgress()">Increase Progress</button> <button onclick="resetProgress()">Reset</button> <script> const progressBar = document.getElementById("progress"); let currentProgress = 0; function increaseProgress() { if (currentProgress < 100) { currentProgress += 5; progressBar.style.width = currentProgress + "px"; } } function resetProgress() { currentProgress = 0; progressBar.style.width = "0px"; } </script> </body> </html> Output:Output Comment More infoAdvertise with us Next Article Creating Progress Bar using JavaScript S Shubrodeep Banerjee Follow Improve Article Tags : Misc JavaScript Web Technologies JavaScript-Misc JavaScript-Questions +1 More Practice Tags : Misc Similar Reads How to Create a Progress Bar using HTML? To create the progress bar of a task by using a <progress> tag. It is used to represent the progress of a task. It is also defined as how much work is done and how much is left. It is not used to represent the disk space or relevant query. Syntax:<progress attributes...> </progress 2 min read How to set/get the value of Progress Bar using JavaScript ? In this article, we are creating the progress bar of a task by using a <progress> tag. The <progress> tag is used to represent the progress of a task. It is also defined how much work is done and how much is left to download a thing. It is not used to represent the disk space or relevant 2 min read How to Create an Image Element using JavaScript? Creating an image element dynamically using JavaScript is a useful technique when you want to add images to a webpage without having to manually write the <img> tag in your HTML. This allows for more flexibility, as we can create and manipulate images based on user interactions or other condit 2 min read Foundation CSS Kitchen Sink Progress Bar Foundation CSS is the frontend framework of CSS that is used to build responsive websites, apps, and emails that work perfectly on any device. It is written using HTML, CSS, and Javascript and is used by many famous companies like Amazon, Facebook, eBay, etc. It uses packages like Grunt and Libsass 2 min read How to create a progress bar using HTML and CSS? The progress bar is an important element in the web, the progress bar can be used for downloading, marks obtained, skill measuring unit, etc. To create a progress bar we can use HTML and CSS. To make that progress bar responsive you will need JavaScript.In this article, we will learn to create progr 1 min read How to create circular progress bar using SVG ? In this article, we will learn how to create a circular progress bar using SVG. Let us begin with the HTML part. In the SVG circle, the cx and cy attributes define the x and y coordinates of the circle. If cx and cy are not taken to the circle's center, it is set to (0,0). The r attribute defines th 3 min read How to create a Multi Step Progress Bar in HTML CSS and JavaScript? In this article, we will create a multi-step progress bar. A Multi-Step Progress Bar is a user interface element created with HTML, CSS, and JavaScript. It guides users through a series of steps or stages, visually displaying their progress and allowing step-by-step navigation in a multi-step proces 3 min read How to make progress bar chart using jQuery? Creating a progress bar chart using jQuery can significantly enhance the visual representation of your data. Whether you are showcasing the age distribution of a group of people or the marks of students in various subjects, a progress bar chart offers an intuitive and visually appealing way to prese 2 min read Create a Circular Progress Bar using HTML and CSS A circular progress bar is a visual representation that shows the progress of a task or operation in a circular form. It's a straightforward and useful way to represent progress and can enhance the appearance of your application or website. So, we will design a circular progress bar using HTML and C 3 min read Create a Bar chart using Recharts in ReactJS Rechart JS is a library that is used for creating charts for React JS. This library is used for building Line charts, Bar charts, Pie charts, etc, with the help of React and D3 (Data-Driven Documents).  To create a Bar Chart using Recharts, we create a dataset with x and y coordinate details. Then 2 min read Like