Objet de couleur d'entrée HTML DOM
Objet de couleur d'entrée
L'objet Input Color représente un élément HTML <input> avec type="color".
Remarque : <input type="color"> n'est pas pris en charge dans IE 11 et les versions antérieures, ni dans Safari 9.1 et les versions antérieures.
Accéder à un objet de couleur d'entrée
Vous pouvez accéder à un élément <input> avec type="color" en utilisant getElementById() :
Exemple
var x = document.getElementById("myColor");
Conseil : Vous pouvez également accéder à <input type="color"> en effectuant une recherche dans la collection d' éléments d'un formulaire.
Créer un objet de couleur d'entrée
Vous pouvez créer un élément <input> avec type="color" en utilisant la méthode document.createElement() :
Exemple
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Propriétés de l'objet Couleur d'entrée
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 |
Propriétés et événements standard
L'objet Couleur d'entrée prend également en charge les propriétés et les événements standard .
Pages connexes
Tutoriel HTML : Formulaires HTML
Référence HTML : balise HTML <input>
Référence HTML : attribut de type HTML <input>