HTML DOM - invoerkleurvoorwerp
Voer kleurvoorwerp in
Die invoerkleur-objek verteenwoordig 'n HTML <invoer>-element met tipe="kleur".
Let wel: <input type="color"> word nie in IE 11 en vroeër weergawes, of in Safari 9.1 en vroeër weergawes ondersteun nie.
Toegang tot 'n invoerkleurvoorwerp
Jy kan toegang verkry tot 'n <input> element met type="color" deur getElementById():
Voorbeeld
var x = document.getElementById("myColor");
Wenk: Jy kan ook toegang tot <input type="color"> kry deur deur die elementversameling van 'n vorm te soek.
Skep 'n invoerkleurvoorwerp
Jy kan 'n <input> element met type="color" skep deur die document.createElement() metode te gebruik:
Voorbeeld
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Voer kleurvoorwerpeienskappe in
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 eiendomme en geleenthede
Die Invoerkleur-objek ondersteun ook die standaard eienskappe en gebeurtenisse .
Verwante bladsye
HTML-tutoriaal: HTML-vorms
HTML-verwysing: HTML <input> tag
HTML verwysing: HTML <invoer> tipe kenmerk