Obiekt koloru wejściowego HTML DOM
Wprowadź kolor obiektu
Obiekt Input Color reprezentuje element HTML <input> z type="color".
Uwaga: <input type="color"> nie jest obsługiwany w IE 11 i wcześniejszych wersjach, ani w Safari 9.1 i wcześniejszych wersjach.
Uzyskaj dostęp do wejściowego obiektu koloru
Możesz uzyskać dostęp do elementu <input> z type="color" za pomocą getElementById():
Przykład
var x = document.getElementById("myColor");
Wskazówka: możesz również uzyskać dostęp do <input type="color"> przeszukując kolekcję elementów formularza.
Utwórz wejściowy obiekt koloru
Możesz utworzyć element <input> z type="color" za pomocą metody document.createElement():
Przykład
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Właściwości obiektu koloru wejściowego
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 |
Standardowe właściwości i zdarzenia
Obiekt Input Color obsługuje również standardowe właściwości i zdarzenia .
Powiązane strony
Samouczek HTML: formularze HTML
Odniesienie HTML: tag HTML <input>
Odniesienie HTML: atrybut typu HTML <input>