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