Input Range defaultValue Property

❮ Input Range Object

Example

Get the default value of a slider control:

var x = document.getElementById("myRange").defaultValue;
Try it Yourself »

Description

The defaultValue property sets or returns the default value of a slider control.

Note: The default value is the value specified in the HTML value attribute.

The difference between the defaultValue and value property, is that defaultValue contains the default value, while value contains the current value after some changes have been made. If there are no changes, defaultValue and value is the same (see "More Examples" below).

The defaultValue property is useful when you want to find out whether the value of a slider control have been changed.


Browser Support

Property
defaultValue Yes 10.0 Yes Yes Yes


Syntax

Return the defaultValue property:

rangeObject.defaultValue

Set the defaultValue property:

rangeObject.defaultValue = value

Property Values

Value Description
value Specifies the default value of the slider control

Technical Details

Return Value: A String, representing the default value of the slider control

More Examples

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 »

❮ Input Range Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.