Javascript Reference - HTML DOM Meter optimum Property








The optimum attribute in the meter element specifies the optimal range value.

The optimum property sets or gets the value of the optimum attribute in a gauge.

Browser Support

optimum Yes No Yes Yes Yes

Syntax

Return the optimum property.

var v = meterObject.optimum

Set the optimum property.

meterObject.optimum=number




Property Values

Value Description
number Set the optimal value of the gauge

Return Value

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

Example

The following code shows how to change the optimum attribute in a gauge.


<!DOCTYPE html>
<html>
<body>
<meter id="myMeter" value="0.3" high="0.9" low="0.1" optimum="0.5"></meter>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from w ww . ja v  a 2s. com-->
    document.getElementById("myMeter").optimum = "0.7";
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

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


<!DOCTYPE html>
<html>
<body>
<meter id="myMeter" value="0.3" high="0.9" low="0.1" optimum="0.5"></meter>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!-- www .ja v a 2  s. co  m-->
<script>
function myFunction() {
    var x = document.getElementById("myMeter").optimum;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: