HTML DOM Input Button Obheto

Input Button object

The Input Button object represents the HTML <input> element that has been set with type="button".

Access Input Button object

You can use getElementById() to access the <input> element with type="button":

var x = document.getElementById("myBtn");

Try It Yourself

Tip:You can also search the form for elements collection to access <input type="button">.

Create Input Button object

You can use the document.createElement() method to create an <input> element with type="button":

var x = document.createElement("INPUT");
x.setAttribute("type", "button");

Try It Yourself

Input Button object attributes

Attributes Description
autofocus Set or return whether the input button should automatically focus when the page is loaded.
defaultValue Set or return the default value of the input button.
disabled Set or return whether the input button is disabled.
form Return a reference to the form that contains the input button.
name Set or return the name attribute value of the input button.
type Return which type of form element the input button is.
value Set or return the value of the input button's value attribute.

Standard attributes and events

Input Button object supports both standardsAttributesatEvents

Related Pages

HTML Tutorial:HTML 表单

HTML Reference Manual:HTML <input> 标签

HTML Reference Manual:HTML <input> type 属性