Input Color value attribute
Example
Modify the default color of the color picker:
document.getElementById("myColor").value = #FF8040;
Try it »
Definition and Usage
The value attribute sets or returns the value of the color picker's value attribute.
The value attribute describes the default color of the color picker.
Note: The default color value is #000000 (black).
Browser support





All major browsers support the value attribute.
**Note:** Internet Explorer and Safari browsers do not support .
Syntax
Return the value attribute:
colorObject
.value
Set the value attribute:
colorObject
.value=
#hexvalue
Attribute values
| Value | Description |
|---|---|
| #hexvalue | Specify the color of the color picker. |
value 必须是一个十六进制值 (hex) :3双位数字, 开始标记为 # (如: #FF8040)。
Note: Color words (e.g., do not use "red" or "blue").
**Note:** The default value is: #000000 (black). |
Technical Details
| Return Value: | A string representing a color value |
|---|
More examples
Example
Get the color of the color picker:
var x = document.getElementById("myColor").value;
x
The output is:
#ff0080
Try it »
Related Articles
HTML Tutorial: HTML color
HTML Tutorial: HTML color value (HEX)
HTML Reference Manual: HTML value attribute
Input Color Object