HTML DOM Input Color Object
Input Color Object
The Input Color object is new in HTML5.
The Input Color object represents an HTML element with a type="color" attribute. element.
Note: Internet Explorer or Safari browser does not support the element using the type="color" attribute.
Accessing the Input Color Object
You can use the getElementById() function to access an element with a type="color" attribute. element:
var x = document.getElementById("myColor");
Try it
Tip: You can also access the Input Color object through a form'sElementcollection.
Creating the Input Color Object
You can use the document.createElement() method to create an element with a type="color" attribute. element:
var x = document.createElement("INPUT");
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 containing the color picker. |
| list | Returns a reference to the datalist containing 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 of the color picker. |
Standard properties and events
The Input Color object also supports standard property and Events.
Related Articles
HTML Tutorial: HTML Forms
HTML Reference Manual: HTML tag
HTML Reference Manual: HTML type Attribute