Example
Change the value of a slider control:
document.getElementById("myRange").value = "75";
Try it Yourself »
Definition and Usage
The value property sets or returns the value of the value attribute of a slider control.
The value attribute specifies the default value OR the value a user types in (or a value set by a script).
Browser Support
The value property is supported in all major browsers.
Note: The <input type="range"> element is not supported in Internet Explorer 9 and earlier versions.
Syntax
Return the value property:
rangeObject.value
Set the value property:
rangeObject.value=number
Property Values
Value | Description |
---|---|
number | Specifies the value of the slider control. If the value is not specified, the default value is "50" |
Technical Details
Return Value: | A String, representing a number that represents the value of the slider control |
---|
More Examples
Example
Get the value of a slider control:
var x = document.getElementById("myRange").value;
The result of x will be:
50
Try it Yourself »
Example
An example that shows the difference between the defaultValue and value property:
var x = document.getElementById("myRange");
var defaultVal =
x.defaultValue;
var currentVal = x.value;
Try it Yourself »
Related Pages
HTML reference: HTML <input> value attribute
< Input Range Object