Javascript Reference - HTML DOM Meter value Property








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

Browser Support

value Yes No Yes Yes Yes

Syntax

Return the value property.

var v = meterObject.value

Set the value property.

meterObject.value=number

Property Values

Value Description
number Set a floating point number for the current value of the gauge




Return Value

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

Example

The following code shows how to get the value 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() {<!-- w ww.j  a  va  2  s  . c  o m-->
    var x = document.getElementById("myMeter").value;
    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 value attribute in a gauge.


<!DOCTYPE html>
<html>
<body>
<meter id="myMeter" min="0" low="40" high="95" max="100" value="65"></meter>
<!--   ww  w.  j av a 2 s.c  om-->
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
    document.getElementById("myMeter").value = "50";
}
</script>
</body>
</html>

The code above is rendered as follows: