Input Color defaultValue Property
Example
Get the default value of a color picker:
var x = document.getElementById("myColor").defaultValue
The result of x will be:
#ff0080
Try it yourself »
Definition and Usage
The defaultValue property sets or returns the default value of a color picker.
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 color of a color picker has been changed.
Browser Support
The defaultValue property is supported in all major browsers.
Note: The <input type="color"> element is not supported in Internet Explorer and Safari.
Syntax
Return the defaultValue property:
colorObject.defaultValue
Set the defaultValue property:
colorObject.defaultValue=value
Property Values
Value | Description |
---|---|
value | Specifies the default value of the color picker |
Technical Details
Return Value: | A String, representing the default value of the color picker |
---|
More Examples
Example
An example that shows the difference between the defaultValue and value property:
var x = document.getElementById("myColor");
var defaultVal =
x.defaultValue;
var currentVal = x.value;
Try it yourself »
Input Color Object