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