Vstupní barevný objekt HTML DOM
Vstupní barevný objekt
Objekt Input Color představuje HTML element <input> s type="color".
Poznámka: <input type="color"> není podporován v IE 11 a starších verzích nebo v Safari 9.1 a starších verzích.
Přístup k objektu vstupní barvy
K prvku <input> s type="color" můžete přistupovat pomocí getElementById():
Příklad
var x = document.getElementById("myColor");
Tip: K <input type="color"> se můžete dostat také prohledáváním kolekce prvků formuláře.
Vytvořte vstupní barevný objekt
Element <input> s type="color" můžete vytvořit pomocí metody document.createElement():
Příklad
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Zadejte vlastnosti objektu barvy
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 |
Standardní vlastnosti a události
Objekt Input Color také podporuje standardní vlastnosti a události .
Související stránky
HTML výukový program: HTML formuláře
HTML reference: HTML tag <input>
HTML reference: HTML <input> typ atributu