
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Range max property
The HTML DOM Input Range max property is used for setting or returning the max attribute value for the range slider control. This attribute is used for indicating the maximum value of the slider control and is often used with min property to create a range of values between which the slider can move.
Syntax
Following is the syntax for −
Setting the Range max property −
rangeObject.max = number
Here, number represents maximum slider control value.
Example
Let us look at an example for the Input range max property −
<!DOCTYPE html> <html> <body> <h1>Range max property</h1> <form> VOLUME <input type="range" id="RANGE1" name="VOL" max="75"> </form> <p>Get the maximum value for the above slider by clicking the below button.</p> <button type="button" onclick="maxVal()">GET MAX</button> <p id="Sample"> </p> <script> function maxVal() { var R= document.getElementById("RANGE1").max; document.getElementById("Sample").innerHTML = "The maximum value for this range slider is "+R; } </script> </body> </html>
Output
This will produce the following output −
On clicking the GET MAX button −
In the above example −
We have created an input field contained inside a form having type=“range”, id=“RANGE1” , name=“VOL” and max attribute value set to 75 −
<form> VOLUME <input type="range" id="RANGE1" name="VOL" max="75"> <form>
We have then created a button GET MAX that will execute the maxVal() method when clicked by the user −
<button type="button" onclick="maxVal()">GET MAX</button>
The maxVal() method uses the getElementById() method to get the input field with type range and its max attribute value. The returned value which signifies the maximum value the slider can have is then assigned to variable R. This value is then displayed in the paragraph with id “Sample” using its innerHTML property −
function maxVal() { var R= document.getElementById("RANGE1").max; document.getElementById("Sample").innerHTML = "The maximum value for this range slider is "+R; }
- Related Articles
- HTML DOM Input Month max Property
- HTML DOM Input Number max Property
- HTML DOM Input Date max Property
- HTML DOM Input Datetime max Property
- HTML DOM Input DatetimeLocal max Property
- HTML DOM Input Time max Property
- HTML DOM Input Week max Property
- HTML DOM Input Range autofocus property
- HTML DOM Input Range disabled property
- HTML DOM Input Range form property
- HTML DOM Input Range min property
- HTML DOM Input Range name property
- HTML DOM Input Range step property
- HTML DOM Input Range type property
- HTML DOM Input Range value property
