Input Range value attribute
Definition and Usage
value
Sets or returns the value of the value attribute of the slider control.
The HTML value attribute specifies the default value or the value entered by the user (or the value set by the script).
See also:
HTML Reference Manual:HTML <input> value Attribute
Example
Example 1
Change the value of the slider control:
document.getElementById("myRange").value = "75";
Example 2
Get the value of the slider control:
var x = document.getElementById("myRange").value;
Example 3
An example to show the difference between the defaultValue and value attributes:
var x = document.getElementById("myRange"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return the value attribute:
rangeObject.value
Set the value attribute:
rangeObject.value = number
Attribute Value
Value | Description |
---|---|
number | Specifies the value of the slider control. If no value is specified, the default value is "50". |
Technical Details
Return Value: | A number representing the value of the slider control. |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |