HTML DOM Button-objekti

Button object

The Button object represents the HTML <button> element.

Access Button object

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

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

Try it yourself

Create Button object

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

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

Try it yourself

Button object properties

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

Standard properties and events

The Button object supports both standardsPropertyandEvent.

Related pages

HTML reference manual:HTML <button> tagi