Input Range defaultValue Attribute
Definition and Usage
defaultValue
Sets or returns the default value of the slider control.
Note:The default value is HTML value attribute specified by the value.
The difference between defaultValue and value properties is that defaultValue contains the default value, while value contains the current value after some changes. If there is no change, defaultValue and value are the same (see the example below).
The defaultValue property is very useful if you want to find out whether the value of the slider control has changed.
Instance
Example 1
Get the default value of the slider control:
var x = document.getElementById("myRange").defaultValue;
Example 2
An example showing the difference between defaultValue and value properties:
var x = document.getElementById("myRange"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return the defaultValue property:
rangeObject.defaultValue
Set the defaultValue property:
rangeObject.defaultValue = value
Attribute Value
Value | Description |
---|---|
value | Specifies the default value of the slider control. |
Technical Details
Return Value: | A string value that represents the default 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 |