HTML DOM Input Color Object
Input Color Object
The Input Color Object is new in HTML5.
The Input Color Object represents an HTML <input> element with the type="color" attribute.
Note:Internet Explorer or Safari browsers do not support the type="color" attribute on <input> elements.
Access an Input Color Object
You can use the getElementById() function to access <input> elements with type="color":
var x = document.getElementById("myColor");
Try it
Tip:You can also, through the form'selementscollection, access the Input Color Object.
Create an Input Color Object
You can use the document.createElement() method to create an <input> element with type="color":
var x = document.createElement("INPUT");
x.setAttribute("type", "color"); Try it
x.setAttribute("type", "color"); Try it
Input Color Object Properties
| Property | Description |
|---|---|
| autocomplete | Sets or returns the autocomplete attribute value of the color picker. |
| autofocus | Sets or returns whether the color picker gets focus when the page loads. |
| defaultValue | Sets or returns the default value of the color picker. |
| disabled | Sets or returns whether the color picker is enabled. |
| form | Returns a reference to the form that contains the color picker. |
| list | Returns a reference to the datalist that contains the color picker. |
| name | Sets or returns the name attribute value of the color picker. |
| type | Returns the form element type of the color picker. |
| value | Sets or returns the value attribute value of the color picker. |
Standard Properties and Events
The Input Color Object also supports standardpropertiesandevents.。
Related Articles
HTML Tutorial:HTML Forms
HTML Reference Manual:HTML <input> tag
HTML Reference Manual:HTML <input> type attribute
Other Extensions