HTML | DOM Input Range max Property

The Input Range max Property in HTML DOM is used to set or return the value of max attribute of the slider control. The max attribute is used to specify the maximum value of slider control.

Syntax:

  • It returns the Input Range max Property:
    rangeObject.max
  • It is used to set Input Range max Property:
    rangeObject.max = number

Property Values: It contains single value number which specify the maximum value allowed for the slider control.

Return Values: It returns a string which represents the maximum allowed value.

Example-1: Returns the Input Range max Property

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        DOM Input Range max Property
    </title>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;"
            GeeksForGeeks 
        </h1>
  
    <h2>DOM Input Range max Property</h2>
  
    <input type="range" 
           id="myRange" 
           min="10" 
           max="50">
  
    <br>
    <br>
  
    <button onclick="myGeeks()">
        Click Here!
    </button>
  
    <p id="GFG"
       style="font-size:23px;
              color:green;">
  </p>
  
    <script>
        function myGeeks() {
  
            // Accessing input value 
            var x =
                document.getElementById(
                  "myRange").max;
            
            document.getElementById(
              "GFG").innerHTML = x;
        }
    </script>
  
</body>
  
</html>

chevron_right


Output:
Before Click on button:

After Click on button:

Example-2: Set Input Range max Property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        DOM Input Range max Property
    </title>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;"
            GeeksForGeeks 
        </h1>
  
    <h2>
      DOM Input Range max Property
  </h2>
  
    <input type="range" 
           id="myRange" 
           min="10"
           max="50">
  
    <br>
    <br>
  
    <button onclick="myGeeks()">
        Click Here!
    </button>
  
    <p id="GFG" 
       style="font-size:23px;
              color:green;">
  </p>
  
    <script>
        function myGeeks() {
  
            // Accessing input value  
            var x =
                document.getElementById(
                  "myRange").max = "70";
  
            document.getElementById(
              "GFG").innerHTML =
                "The value of the max attribute"+
              " was changed to " + x;
        }
    </script>
  
</body>
  
</html>

chevron_right


Output:
Before Click on button:

After Click on button:

Supported Browsers: The browser supported by DOM Input Range max Property are listed below:

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


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.