HTML DOM -invoerkleurobject
Invoerkleurobject
Het Input Color-object vertegenwoordigt een HTML <input>-element met type="color".
Opmerking: <input type="color"> wordt niet ondersteund in IE 11 en eerdere versies, of in Safari 9.1 en eerdere versies.
Toegang tot een invoerkleurobject
U kunt toegang krijgen tot een <input>-element met type="color" met behulp van getElementById():
Voorbeeld
var x = document.getElementById("myColor");
Tip: U kunt ook toegang krijgen tot <input type="color"> door te zoeken in de elementenverzameling van een formulier.
Een invoerkleurobject maken
U kunt een <input>-element maken met type="color" met behulp van de document.createElement()-methode:
Voorbeeld
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Eigenschappen invoerkleurobject
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 |
Standaard eigenschappen en evenementen
Het Input Color-object ondersteunt ook de standaardeigenschappen en events .
Gerelateerde pagina's
HTML-zelfstudie: HTML-formulieren
HTML-referentie: HTML <input>-tag
HTML-referentie: HTML <input> type attribuut