HTML | DOM meter Object

The DOM Meter Object is used to represent the HTML <meter> element. The meter element is accessed by getElementById().

Properties:

  • form: It belongs to one or more forms that it belongs too.
  • max: It is used to specify the maximum value of a range.
  • min: It is used to specify the minimum value of a range.
  • high: It is used to specify the range considered to be a high value.
  • low: It is used to specify the range value that is considered to be low.
  • Optimum: It is used to specify the optimum value for the range.
  • value: It is used to specify the required or actual value of the range.

Syntax:

document.getElementById("ID");

Where “id” is the ID assigned to the “meter” tag.

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>DOM Meter Object</title>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>DOM Meter Object:</h2> Sachin's score:
    
    <!-- assigning id to meter with 
         properties. -->
    <meter id="GFG" 
           value="5" 
           min="0" 
           max="10">
      5 out of 10
    </meter>
    
    <br>Laxma score:
  
    <!-- meter tag using value property. -->
    <meter value="0.5">50% from 100% </meter>
    <br>
    
    <button onclick="Geeks()">
      Submit
    </button>
    
    <p id="sudo"></p>
    
    <script>
        function Geeks() {
              
            //  Accessing 'meter' tag.
            var g = 
             document.getElementById("GFG").value;
            document.getElementById("sudo").innerHTML = g;
        }
    </script>
    
</body>
  
</html>                                         

chevron_right


Output:

Before Clicking On Button :

After Clicking On Buttton:

Example-2: Meter Object can be created by using the document.createElement method.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>DOM Meter Object</title>
  
    <style>
        body {
            font-size: 20px;
        }
    </style>
</head>
  
<body style="text-align:center;">
    <form>
        <h1 style="color:green">GeeksforGeeks</h1>
        <h2>DOM Meter Object</h2>
  
        <p id="GFG">Sachins score:</p>
    </form>
    <button onclick="myGeeks()">Submit</button>
    <script>
        function myGeeks() {
  
            //  Creating meter object using
            //  document.createElement.
            var g = document.createElement("METER");
            g.setAttribute("min", "0");
            g.setAttribute("max", "10");
            g.setAttribute("value", "5");
            document.body.appendChild(g);
        }
    </script>
</body>
  
</html>

chevron_right


Output:

Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browser supported by DOM Meter Object are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.