Input type hidden property defaultValue in Javascript
The Input type hidden property defaultValue used to set and retrieve the default value of the hidden input field. It returns a string that represents the default value of the hidden input field.
Syntax
 1 <input>.defaultValue // to retrieve
 2 <input>.defaultValue = <string> // to set
input : A input type hidden element object to set and retrieve defaultValue property
string : It specifies the default value for the hidden input field
Input hidden property defaultValue
 1 <!DOCTYPE html>
 2 <html>
 3 <style>
 4   .container {
 5     margin: 20px 0;
 6   }
 7 </style>
 8 <body>
 9 	<h1>The Input hidden Object</h1>
 10 	<h2>Example</h2>
 11 	
 12 	<div class="container">
 13 	  <input id="hidden" type="hidden" value="Default"/>
 14 	</div>
 15 
 16 	<button onclick="access()">Access</button>
 17 	<p id="result"></p>
 18 	<script>
 19 	function access() {
 20 	  const element = document.getElementById("hidden");
 21 	  const str = `The default value : <b>${element.defaultValue}</b>`;
 22 	  document.getElementById("result").innerHTML = str;	  
 23 	}
 24 	</script>
 25 </body>
 26 </html>
Input hidden property defaultValue
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us