Цветовой объект ввода HTML DOM
Входной цветной объект
Объект Input Color представляет элемент HTML <input> с type="color".
Примечание. <input type="color"> не поддерживается в IE 11 и более ранних версиях, а также в Safari 9.1 и более ранних версиях.
Доступ к объекту входного цвета
Вы можете получить доступ к элементу <input> с type="color" с помощью getElementById():
Пример
var x = document.getElementById("myColor");
Совет: Вы также можете получить доступ к <input type="color">, выполнив поиск в коллекции элементов формы.
Создайте объект входного цвета
Вы можете создать элемент <input> с type="color" с помощью метода document.createElement():
Пример
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Свойства входного цветного объекта
Property | Description |
---|---|
autocomplete | Sets or returns the value of the autocomplete attribute of a color picker |
autofocus | Sets or returns whether a color picker should automatically get focus when the page loads |
defaultValue | Sets or returns the default value of a color picker |
disabled | Sets or returns whether a color picker is disabled, or not |
form | Returns a reference to the form that contains the color picker |
list | Returns a reference to the <datalist> element that contains the color picker |
name | Sets or returns the value of the name attribute of a color picker |
type | Returns which type of form element the color picker is |
value | Sets or returns the value of the value attribute of a color picker |
Стандартные свойства и события
Объект Input Color также поддерживает стандартные свойства и события .
Связанные страницы
Учебник по HTML: HTML-формы
Справочник по HTML: HTML-тег <input>
Справочник по HTML: HTML-атрибут типа <input>