Javascript Reference - HTML DOM Progress max Property








The max property sets or gets the value of the max attribute of a progress bar.

Browser Support

max Yes 10.0 Yes Yes Yes

Syntax

Return the max property.

var v = progressObject.max

Set the max property.

progressObject.max=number

Property Values

Value Description
number Set how much work the task requires in total




Return Value

A floating point number representing how much work the task requires in total.

Example

The following code shows how to Get the maximum value of a progress bar.


<!DOCTYPE html>
<html>
<body>
<progress id="myProgress" value="25" max="100"></progress>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--   w w  w  . j  a v a 2  s .  c  om-->
    var x = document.getElementById("myProgress").max;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to change the maximum value in a progress bar.


<!DOCTYPE html>
<html>
<body>
<progress id="myProgress" value="25" max="100"></progress>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--  w  w w .jav  a2  s  . com-->
    document.getElementById("myProgress").max = "50";
}
</script>
</body>
</html>

The code above is rendered as follows: