HTML | DOM Button form Property
The Button form property in HTML DOM is used to return the reference of the form containing the button. It is a read-only property and returns the form object on success.
Syntax:
buttonObject.form
Return Value: It returns a reference to the form element containing the button. It returns NULL if the button is not in the form.
Example: This example shows the working of the Button form property:
<!DOCTYPE html> <html> <head> <title> HTML DOM Button form Property </title> </head> <body> <h1 style = "color:green">GeeksforGeeks</h1> <h2>DOM Button form Property</h2> <form id="users"> <button onclick = "myGeeks()" id ="btn" type="button"> Get form ID </button> </form> <p id = "GFG"></p> <!-- Script to get the form ID --> <script> function myGeeks() { var x = document.getElementById("btn").form.id; document.getElementById("GFG").innerHTML = x; } </script> </body> </html> |
Output:
- Before clicking the button:

- After clicking the button:

Supported Browsers: The browser supported by HTML DOM Button form Property are listed below:
- Google Chrome
- Internet Explorer
- Mozilla Firefox
- Safari
- Opera
Recommended Posts:
- HTML | DOM Input Button form Property
- HTML | <button> form Attribute
- HTML | DOM Button value Property
- HTML | DOM Button name Property
- HTML | DOM Button formAction Property
- HTML | DOM Input Button name Property
- HTML | DOM Input Button value Property
- HTML | DOM Button type Property
- HTML | DOM Button formNoValidate Property
- HTML | DOM Button formEnctype Property
- HTML | DOM Button formMethod Property
- HTML | DOM Button autofocus Property
- HTML | DOM Button disabled Property
- HTML | DOM Button formTarget Property
- HTML | DOM Input Button type Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



