Javascript Reference - HTML DOM Meter max Property








The max property sets or gets the max attribute in a gauge.

The max attribute from meter element specifies the upper bound of the gauge, and the value must be greater than the min attribute value.

If unspecified, the default value is 1.

Browser Support

max Yes No Yes Yes Yes

Syntax

Return the max property.

var v = meterObject.max

Set the max property.

meterObject.max=number




Property Values

Value Description
number Set the maximum value of the gauge. Default value is 1

Return Value

A Number type value representing the maximum value of the gauge.

Example

The following code shows how to get the max attribute in a gauge.


<!DOCTYPE html>
<html>
<body>
<meter id="myMeter" min="0" low="40" high="95" max="100" value="65"></meter>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from w w w  . j av a 2s . c  o m-->
    var x = document.getElementById("myMeter").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 max attribute in a gauge.


<!DOCTYPE html>
<html>
<body>
<meter id="myMeter" min="0" low="40" high="75" max="100" value="65"></meter>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--  ww  w  .ja v a 2s.  c o m-->
    document.getElementById("myMeter").max = "80";
}
</script>
</body>
</html>

The code above is rendered as follows: