HTMLButtonElement - Web APIs | MDN

  • Skip to main content
  • Skip to search
HTMLButtonElement Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

* Some parts of this feature may have varying levels of support.

  • Learn more
  • See full compatibility
  • Report feedback

The HTMLButtonElement interface provides properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <button> elements.

EventTarget Node Element HTMLElement HTMLButtonElement

In this article

  • Instance properties
  • Instance methods
  • Specifications
  • Browser compatibility
  • See also

Instance properties

Inherits properties from its parent, HTMLElement.

HTMLButtonElement.command

A string value indicating the action to be performed on an element being controlled by this button.

HTMLButtonElement.commandForElement

A reference to an existing Element that the button controls.

HTMLButtonElement.disabled

A boolean value indicating whether or not the control is disabled, meaning that it does not accept any clicks.

HTMLButtonElement.form Read only

An HTMLFormElement reflecting the form that this button is associated with. If the button is a descendant of a form element, then this attribute is a reference to that form's associated HTMLFormElement. If the button is not a descendant of a form element, then the attribute can be a reference to any HTMLFormElement element in the same document it is related to, or the null value if none matches.

HTMLButtonElement.formAction

A string reflecting the URI of a resource that processes information submitted by the button. If specified, this attribute overrides the action attribute of the <form> element that owns this element.

HTMLButtonElement.formEnctype

A string reflecting the type of content that is used to submit the form to the server. If specified, this attribute overrides the enctype attribute of the <form> element that owns this element.

HTMLButtonElement.formMethod

A string reflecting the HTTP method that the browser uses to submit the form. If specified, this attribute overrides the method attribute of the <form> element that owns this element.

HTMLButtonElement.formNoValidate

A boolean value indicating that the form is not to be validated when it is submitted. If specified, this attribute overrides the novalidate attribute of the <form> element that owns this element.

HTMLButtonElement.formTarget

A string reflecting a name or keyword indicating where to display the response received after submitting the form. If specified, this attribute overrides the target attribute of the <form> element that owns this element.

HTMLButtonElement.interestForElement Experimental Non-standard

Gets or sets the target element of an interest invoker, in cases where the associated <button> element is specified as an interest invoker.

HTMLButtonElement.labels Read only

A NodeList that represents a list of <label> elements that are labels for this button.

HTMLButtonElement.name

A string representing the object's name when submitted with a form. If specified, it must not be the empty string.

HTMLButtonElement.popoverTargetAction

Gets and sets the action to be performed ("hide", "show", or "toggle") on a popover element being controlled by a control button. It reflects the value of the popovertargetaction HTML attribute.

HTMLButtonElement.popoverTargetElement

Gets and sets the popover element to control via a button. The JavaScript equivalent of the popovertarget HTML attribute.

HTMLButtonElement.type

A string indicating the behavior of the button. This is an enumerated attribute with the following possible values:

  • submit: The button submits the form. This is the default value if the attribute is not specified, or if it is dynamically changed to an empty or invalid value.
  • reset: The button resets the form.
  • button: The button does nothing.
  • menu: The button displays a menu. Experimental
HTMLButtonElement.willValidate Read only

A boolean value indicating whether the button is a candidate for constraint validation. It is false if any conditions bar it from constraint validation, including: its type property is reset or button; it has a <datalist> ancestor; or the disabled property is set to true.

HTMLButtonElement.validationMessage Read only

A string representing the localized message that describes the validation constraints that the control does not satisfy (if any). This attribute is the empty string if the control is not a candidate for constraint validation (willValidate is false), or it satisfies its constraints.

HTMLButtonElement.validity Read only

A ValidityState representing the validity states that this button is in.

HTMLButtonElement.value

A string representing the current form control value of the button.

Instance methods

Inherits methods from its parent, HTMLElement.

HTMLButtonElement.checkValidity()

Returns true if the element's value has no validity problems; otherwise, returns false.

HTMLButtonElement.reportValidity()

Performs the same action as checkValidity(), but also reports the result to the user if the invalid event was not canceled.

HTMLButtonElement.setCustomValidity()

Sets the custom validity message for the element. Use the empty string to indicate that the element does not have a custom validity error.

Specifications

Specification
HTML# htmlbuttonelement

Browser compatibility

See also

  • HTML element implementing this interface: <button>

Help improve MDN

Was this page helpful to you? Yes No Learn how to contribute

This page was last modified on ⁨Dec 8, 2025⁩ by MDN contributors.

View this page on GitHub • Report a problem with this content Filter sidebar
  1. The HTML DOM API
  2. HTMLButtonElement
  3. Instance properties
    1. command
    2. commandForElement
    3. disabled
    4. form
    5. formAction
    6. formEnctype
    7. formMethod
    8. formNoValidate
    9. formTarget
    10. interestForElement Experimental Non-standard
    11. labels
    12. name
    13. popoverTargetAction
    14. popoverTargetElement
    15. type
    16. validationMessage
    17. validity
    18. value
    19. willValidate
  4. Instance methods
    1. checkValidity()
    2. reportValidity()
    3. setCustomValidity()
  5. Inheritance
    1. HTMLElement
    2. Element
    3. Node
    4. EventTarget
  6. Related pages for HTML DOM
    1. BeforeUnloadEvent
    2. DOMStringMap
    3. ErrorEvent
    4. HTMLAnchorElement
    5. HTMLAreaElement
    6. HTMLAudioElement
    7. HTMLBRElement
    8. HTMLBaseElement
    9. HTMLBodyElement
    10. HTMLCanvasElement
    11. HTMLDListElement
    12. HTMLDataElement
    13. HTMLDataListElement
    14. HTMLDialogElement
    15. HTMLDivElement
    16. HTMLDocument
    17. HTMLElement
    18. HTMLEmbedElement
    19. HTMLFieldSetElement
    20. HTMLFormControlsCollection
    21. HTMLFormElement
    22. HTMLFrameSetElement Deprecated
    23. HTMLHRElement
    24. HTMLHeadElement
    25. HTMLHeadingElement
    26. HTMLHtmlElement
    27. HTMLIFrameElement
    28. HTMLImageElement
    29. HTMLInputElement
    30. HTMLLIElement
    31. HTMLLabelElement
    32. HTMLLegendElement
    33. HTMLLinkElement
    34. HTMLMapElement
    35. HTMLMediaElement
    36. HTMLMenuElement
    37. HTMLMetaElement
    38. HTMLMeterElement
    39. HTMLModElement
    40. HTMLOListElement
    41. HTMLObjectElement
    42. HTMLOptGroupElement
    43. HTMLOptionElement
    44. HTMLOptionsCollection
    45. HTMLOutputElement
    46. HTMLParagraphElement
    47. HTMLPictureElement
    48. HTMLPreElement
    49. HTMLProgressElement
    50. HTMLQuoteElement
    51. HTMLScriptElement
    52. HTMLSelectElement
    53. HTMLSourceElement
    54. HTMLSpanElement
    55. HTMLStyleElement
    56. HTMLTableCaptionElement
    57. HTMLTableCellElement
    58. HTMLTableColElement
    59. HTMLTableElement
    60. HTMLTableRowElement
    61. HTMLTableSectionElement
    62. HTMLTemplateElement
    63. HTMLTextAreaElement
    64. HTMLTimeElement
    65. HTMLTitleElement
    66. HTMLTrackElement
    67. HTMLUListElement
    68. HTMLUnknownElement
    69. HTMLVideoElement
    70. HashChangeEvent
    71. History
    72. ImageData
    73. Location
    74. MessageChannel
    75. MessageEvent
    76. MessagePort
    77. Navigator
    78. PageRevealEvent
    79. PageSwapEvent
    80. PageTransitionEvent
    81. Plugin Deprecated
    82. PluginArray Deprecated
    83. PromiseRejectionEvent
    84. RadioNodeList
    85. TimeRanges
    86. UserActivation
    87. ValidityState
    88. Window
    89. WorkletGlobalScope
  7. Guides
    1. Using microtasks in JavaScript with queueMicrotask()
    2. In depth: Microtasks and the JavaScript runtime environment

Từ khóa » Html Button Properties Javascript