Objek Warna Masukan DOM HTML
Masukan Objek Warna
Objek Input Color mewakili elemen <input> HTML dengan type="color".
Catatan: <input type="color"> tidak didukung di IE 11 dan versi sebelumnya, atau di Safari 9.1 dan versi sebelumnya.
Mengakses Objek Warna Masukan
Anda dapat mengakses elemen <input> dengan type="color" dengan menggunakan getElementById():
Contoh
var x = document.getElementById("myColor");
Tip: Anda juga dapat mengakses <input type="color"> dengan mencari melalui kumpulan elemen formulir.
Buat Objek Warna Masukan
Anda dapat membuat elemen <input> dengan type="color" dengan menggunakan metode document.createElement():
Contoh
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
Properti Objek Warna Masukan
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 |
Properti dan Acara Standar
Objek Input Color juga mendukung properti dan event standar .
Halaman Terkait
Tutorial HTML: Formulir HTML
Referensi HTML: tag HTML <input>
Referensi HTML: Atribut tipe <input> HTML