Easy Tutorial
❮ Prop Meta Content Met Document Createelement ❯

Radio defaultChecked Property


Definition and Usage

The defaultChecked property returns the default value of the checked attribute.

It returns true if the radio button's default state is checked, otherwise it returns false.

Syntax


Browser Support

All major browsers support the defaultChecked property.


Example

Check if the "Blue" option is default checked:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function displayResult(){
    var x=document.getElementById("blue").defaultChecked;
    alert(x);
}
</script>
</head>
<body>

<form>
Which color do you prefer?<br>
<input type="radio" name="colors" id="red">Red<br>
<input type="radio" name="colors" id="blue" checked="checked">Blue<br>
<input type="radio" name="colors" id="green">Green
</form>
<button type="button" onclick="displayResult()">Is Blue the default selection?</button>

</body>
</html>

❮ Prop Meta Content Met Document Createelement ❯