HTML DOM Button Object

Button Object

The Button object represents the HTML <button> element.

Accessing Button Object

You can access the <button> element using getElementById():

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

Try It Yourself

Creating Button Object

You can create a <button> element using the document.createElement() method:

var x = document.createElement("BUTTON");

Try It Yourself

Button Object Properties

Properties Description
autofocus Sets or returns whether the button should automatically focus when the page is loaded.
disabled Sets or returns whether the button is disabled.
form Returns a reference to the form that contains the button.
formAction Sets or returns the value of the button's formaction attribute.
formEnctype Sets or returns the value of the button's formenctype attribute.
formMethod Sets or returns the value of the button's formmethod attribute.
formNoValidate Sets or returns whether form data should be validated when submitted.
formTarget Sets or returns the value of the button's formtarget attribute.
name Sets or returns the value of the button's name property.
type Sets or returns the type of the button.
value Sets or returns the value of the button's value property.

Standard properties and events

The Button object supports both standardPropertiesAndEvents.

Related Pages

HTML Reference Manual:HTML <button> Tag