Objeto de color de entrada HTML DOM
Objeto de color de entrada
El objeto Input Color representa un elemento HTML <input> con type="color".
Nota: <input type="color"> no es compatible con IE 11 y versiones anteriores, ni con Safari 9.1 y versiones anteriores.
Acceder a un objeto de color de entrada
Puede acceder a un elemento <input> con type="color" usando getElementById():
Ejemplo
var x = document.getElementById("myColor");
Sugerencia: también puede acceder a <input type="color"> buscando en la colección de elementos de un formulario.
Crear un objeto de color de entrada
Puede crear un elemento <input> con type="color" usando el método document.createElement():
Ejemplo
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Propiedades del objeto de color 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 |
Propiedades y eventos estándar
El objeto Color de entrada también es compatible con las propiedades y los eventos estándar .
páginas relacionadas
Tutorial de HTML: formularios HTML
Referencia HTML: etiqueta HTML <input>
Referencia HTML: atributo de tipo HTML <entrada>