Button form Attribute

Definition and Usage

form The attribute returns a reference to the form containing the button.

form The attribute returns the form object on success.

Note:This property is read-only.

Example

Returns the id of the form to which the button belongs:

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

Try It Yourself

Syntax

buttonObject.form

Technical Details

Return Value: Reference to form elements containing buttons. If the button is not in the form, it returns null.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support