HTML | DOM Input Hidden value Property - GeeksforGeeks

20 Jan, 2022
The Input Hidden value property in HTML DOM is used to set or return the value of the value attribute of the hidden input field. The value attribute defines the default value of the input hidden field.
Syntax:
It returns the value property.hiddenObject.value
hiddenObject.value
It is used to set the value property.hiddenObject.value = text
hiddenObject.value = text
Property Values: This property contains single value text which is used to specify the initial value of the input hidden field.
Return Value: It returns a string value which represent the value of the value attribute of the hidden input field.
Example 1: This example illustrates how to return the hidden value property.
html
<!DOCTYPE html><html>      <head>    <title>        HTML DOM Input Hidden value Property    </title></head>    <body style="text-align:center;">      <h1 style="color:green;">        GeeksForGeeks     </h1>          <h2>DOM Input Hidden value Property</h2>          <input type="hidden" id="GFG"                value="GeeksForGeeks">                <button onclick="myGeeks()">        Submit    </button>          <p id="sudo" style="color:green;font-size:35px;"></p>          <!-- Script to return the hidden value -->    <script>        function myGeeks() {            var x = document.getElementById("GFG").value;            document.getElementById("sudo").innerHTML = x;        }    </script></body>  </html>                    
Example 2: This example illustrate how to set the hidden property.
html
<!DOCTYPE html><html>      <head>    <title>        HTML DOM Input Hidden value Property    </title></head>    <body style="text-align:center;">      <h1 style="color:green;">        GeeksForGeeks     </h1>          <h2>DOM Input Hidden value Property</h2>      <input type="hidden" id="GFG" value="GeeksForGeeks">          <button onclick="myGeeks()">        Submit    </button>          <p id="sudo" style="color:green;font-size:20px;"></p>          <!-- Script to set hidden property value -->    <script>        function myGeeks() {            var x = document.getElementById("GFG").value                    = "Sudo Placement";            document.getElementById("sudo").innerHTML                    = "The value of the value attribute"                    + " have changed to " + x;        }    </script></body>  </html>                    
Supported Browsers: The browser supported by DOM input Hidden value Property are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
hritikbhatnagar2182
chhabradhanvi
HTML-DOM
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript