Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML DOM Input Color object


May 06, 2021 JavaScript with HTML DOM Reference book


Table of contents


HTML DOM Input Color object


Input Color object

The Input Color object is new to HTML5.

The Input Color object represents the HTML-lt;input-gt; element that uses the type-"color" property.

Note: Internet Explorer or Safari does not support the use of the type-"color" property by the element.

Access the Input Color object

You can use the getElementById() function to access the elements that use the type"color" property:

var x = document.getElementById("myColor"); Give it a try

Tip: You can also access the Input Color object through the form's collection of elements.

Create an Input Color object

You can use the document.createElement() method to create an element that uses the type-"color" property:

var x = document.createElement("INPUT");
x.setAttribute("type", "color"); Give it a try

Input Color object properties

Property Describe
autocomplete Set or return the autocomplete property value of the color picker.
autofocus Set or return whether the color picker gets focus when the page loads.
defaultValue Set or return the default value for the color picker.
disabled Set or return whether the color picker is available.
form Returns a form reference that contains a color picker.
list Returns a datalist reference that contains the color picker.
name Set or return the color picker name property value.
type Returns the type of form element for the color picker.
value Set or return the value property value of the color picker.

Standard properties and events

Input Color objects also support standard properties and events.


Related articles

HTML tutorial: HTML forms

HTML Reference Manual: HTML slt;input.gt; Tags

HTML Reference Manual: HTML slt;input> type property