Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | DOM Button form Property

Improve Article
Save Article
  • Last Updated : 21 Jul, 2022
Improve Article
Save Article

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. 



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 DOM Button form Property
    <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
    <p id = "GFG"></p>
    <!-- Script to get the form ID -->
        function myGeeks() {
            var x = document.getElementById("btn");
            document.getElementById("GFG").innerHTML = x;


  • Before clicking the button:


  • After clicking the button:


Supported Browsers: The browser supported by HTML DOM Button form Property are listed below:

  • Google Chrome
  • Edge 16 and above
  • Internet Explorer not supported
  • Mozilla Firefox
  • Safari
  • Opera
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!