HTMLDOM入力チェックボックスオブジェクト
チェックボックスオブジェクトを入力します
Input Checkboxオブジェクトは、type = "checkbox"のHTML <input>要素を表します。
入力チェックボックスオブジェクトにアクセスする
getElementById()を使用して、type = "checkbox"で<input>要素にアクセスできます。
例
var x = document.getElementById("myCheck");
ヒント:フォームの要素コレクションを検索して、<input type = "checkbox">にアクセスすることもできます。
入力チェックボックスオブジェクトを作成する
document.createElement()メソッドを使用して、type = "checkbox"で<input>要素を作成できます。
例
var x = document.createElement("INPUT");
x.setAttribute("type", "checkbox");
チェックボックスオブジェクトのプロパティを入力
Property | Description |
---|---|
autofocus | Sets or returns whether a checkbox should automatically get focus when the page loads |
checked | Sets or returns the checked state of a checkbox |
defaultChecked | Returns the default value of the checked attribute |
defaultValue | Sets or returns the default value of a checkbox |
disabled | Sets or returns whether a checkbox is disabled, or not |
form | Returns a reference to the form that contains the checkbox |
indeterminate | Sets or returns the indeterminate state of the checkbox |
name | Sets or returns the value of the name attribute of a checkbox |
required | Sets or returns whether the checkbox must be checked before submitting a form |
type | Returns which type of form element the checkbox is |
value | Sets or returns the value of the value attribute of a checkbox |
標準のプロパティとイベント
入力チェックボックスオブジェクトは、標準のプロパティとイベントもサポートしています。
関連ページ
HTMLチュートリアル:HTMLフォーム
HTMLリファレンス:HTML <input>タグ
HTML参照:HTML <input>タイプ属性