HTML-DOM - Eingabefarbobjekt
Farbobjekt eingeben
Das Input Color-Objekt repräsentiert ein HTML-<input>-Element mit type="color".
Hinweis: <input type="color"> wird in IE 11 und früheren Versionen oder in Safari 9.1 und früheren Versionen nicht unterstützt.
Greifen Sie auf ein Eingabefarbobjekt zu
Sie können auf ein <input>-Element mit type="color" zugreifen, indem Sie getElementById() verwenden:
Beispiel
var x = document.getElementById("myColor");
Tipp: Sie können auch auf <input type="color"> zugreifen, indem Sie die Elementsammlung eines Formulars durchsuchen .
Erstellen Sie ein Eingabefarbobjekt
Sie können ein <input>-Element mit type="color" erstellen, indem Sie die Methode document.createElement() verwenden:
Beispiel
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Eigenschaften des Eingabefarbobjekts
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 |
Standardeigenschaften und -ereignisse
Das Input Color-Objekt unterstützt auch die Standardeigenschaften und -ereignisse .
Verwandte Seiten
HTML-Tutorial: HTML-Formulare
HTML-Referenz: HTML-<input>-Tag
HTML-Referenz: HTML-Attribut vom Typ <input>