Javascript Reference - HTML DOM Meter Object








The Meter object represents an HTML <meter> element.

Meter Object Properties

Property Description
high Sets or gets the high attribute in a gauge
labels Get a list of <label> elements labeling the gauge
low Sets or gets the low attribute in a gauge
max Sets or gets the max attribute in a gauge
min Sets or gets the min attribute in a gauge
optimum Sets or gets the optimum attribute in a gauge
value Sets or gets the value attribute in a gauge




Standard Properties and Events

The Meter object supports the standard properties and events.

Example

We can access a <meter> element by using getElementById().


<!DOCTYPE html>
<html>
<body>
<!--from   ww  w .  j  a v a 2s . c  o m-->
<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() {
    var x = document.getElementById("myMeter").value;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

We can create a <meter> element by using the document.createElement() method.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from  www  .j a v  a  2  s  . c o  m-->
    var x = document.createElement("METER");
    x.setAttribute("min", "0");
    x.setAttribute("max", "100");
    x.setAttribute("value", "65");
    document.body.appendChild(x);
}
</script>

</body>
</html>

The code above is rendered as follows: