Objeto de cor de entrada HTML DOM
Objeto de cor de entrada
O objeto Input Color representa um elemento HTML <input> com type="color".
Observação: <input type="color"> não é compatível com o IE 11 e versões anteriores, ou no Safari 9.1 e versões anteriores.
Acessar um objeto de cor de entrada
Você pode acessar um elemento <input> com type="color" usando getElementById():
Exemplo
var x = document.getElementById("myColor");
Dica: Você também pode acessar <input type="color"> pesquisando na coleção de elementos de um formulário.
Criar um objeto de cor de entrada
Você pode criar um elemento <input> com type="color" usando o método document.createElement():
Exemplo
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Propriedades do objeto de cor de entrada
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 |
Propriedades e eventos padrão
O objeto Input Color também suporta as propriedades e eventos padrão .
Páginas relacionadas
Tutorial HTML: Formulários HTML
Referência HTML: tag HTML <input>
Referência HTML: atributo de tipo HTML <input>