HTML | DOM Label form Property

The HTML DOM Label form Property is used for returning the reference to the form containing the Label Element. It is read-only Property that returns a form object on success.

Syntax:

labelObject.form

Return Value: It returns a reference that contains the label and null if the label is not in the form returns a form.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html>
  
<head>
    <title>DOM Label Form Property</title>
  
    <style>
        body {
            font-size: 20px;
        }
    </style>
</head>
  
<body style="text-align:center">
  
    <h1 style="color:green">GeeksforGeeks</h1>
    <h2> HTML DOM Label Form Property</h2>
  
    <form id="geeks">
  
        <!-- Starts label tag from here -->
        <label id="sudo" for="student">
            Student
        </label>
        <input type="radio" 
               name="Occupation"
               id="student" 
               value="student">
        <br>
  
        <label for="business">
            Business
        </label>
        <input type="radio" 
               name="Occupation" 
               id="business"
               value="business">
        <br>
  
        <label for="other">
            Other
        </label>
        <!-- Ends label tags here -->
  
        <input type="radio"
               name="Occupation" 
               id="other" 
               value="other">
    </form>
    <br>
    <button onclick="myGeeks()">Submit</button>
    <p id="gfg"></p>
    <script>
        function myGeeks() {
            var g = document.getElementById("sudo").form.id;
            document.getElementById("gfg").innerHTML = g;
        }
    </script>
</body>
  
</html>

chevron_right


Output:
Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browsers supported by DOM Label form Property are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.