HTMLDOM入力カラーオブジェクト
入力カラーオブジェクト
Input Colorオブジェクトは、type = "color"のHTML <input>要素を表します。
注: <input type = "color">は、IE 11以前のバージョン、またはSafari9.1以前のバージョンではサポートされていません。
入力カラーオブジェクトにアクセスする
getElementById()を使用して、type = "color"で<input>要素にアクセスできます。
例
var x = document.getElementById("myColor");
ヒント:フォームの要素コレクションを検索して、<input type = "color">にアクセスすることもできます。
入力カラーオブジェクトを作成する
document.createElement()メソッドを使用して、type = "color"で<input>要素を作成できます。
例
var x = document.createElement("INPUT");
x.setAttribute("type", "color");
入力カラーオブジェクトのプロパティ
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 |
標準のプロパティとイベント
Input Colorオブジェクトは、標準のプロパティとイベントもサポートしています。
関連ページ
HTMLチュートリアル:HTMLフォーム
HTMLリファレンス:HTML <input>タグ
HTML参照:HTML <input>タイプ属性