HTML | DOM Progress Object

The Progress Object in HTML DOM is used to represent the HTML <progress> element. The <progress> element can be accessed by using getElementById() method.

Property Values:

  • level: It returns the list of progress bar.
  • max: It is used to set or return the progress bar value of max attribute.
  • value: It represent the amount of work are already completed.
  • position: It returns the current position of progress bar.

Syntax:

document.getElementById("ID");

Where ID is assigned to the <progress> element.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
    <head
        <title>
            HTML DOM Progress Object
        </title
    </head>
      
    <body
        <h1 style="color:green;">
            GeeksForGeeks
        </h1
          
        <h2>DOM Progress Object</h2>
          
        Downloading progress for a song:
        <progress id = "GFG" value = "57" max = "100"
        </progress
          
        <br><br>
          
        <button onclick = "myGeeks()">
            Submit
        </button>
          
        <p id = "sudo"></p>
          
        <script>
            function myGeeks() {
                var pr = document.getElementById("GFG").value;
                document.getElementById("sudo").innerHTML = pr;
            }
        </script>
    </body
</html>                              

chevron_right


Output:
Before Click on the Button:

After Click on the Button:

Example 2: Progress Object can be created by using the document.createElement Method.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
    <head
        <title>
            HTML DOM Progress Object
        </title
    </head
      
    <body
        <h1 style = "color:green;">
            GeeksForGeeks
        </h1
          
        <h2>DOM Progress Object</h2>
          
        <P id = "GFG">
            Downloading progress for a song: 
        </p
          
        <button onclick = "myGeeks()">
            Submit
        </button>
          
        <script>
            function myGeeks() {
                var g = document.createElement("PROGRESS");
                g.setAttribute("value", "57");
                g.setAttribute("max", "100");
                document.getElementById("GFG").appendChild(g);
            }
        </script>
    </body
</html>                              

chevron_right


Output:
Before Click on the Button:

After Click on the Button:

Supported Browsers: The browser supported by DOM Progress Object are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.