Radio checkedProperty
Radio Object
Definition and Usage
The checked property sets or returns whether a radio button is checked.
Syntax
Set the checked property:
radioObject.checked=true|false
Return the checked property:
radioObject.checked
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the checked property
Examples
Examples
The following example can select and deselect a radio button:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function check(){
document.getElementById("red").checked=true
}
function uncheck(){
document.getElementById("red").checked=false
}
</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">Blue<br>
<input type="radio" name="colors" id="green">Green
</form>
<button type="button" onclick="check()">Select "Red"</button>
<button type="button" onclick="uncheck()">Deselect "Red"</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function check(){
document.getElementById("red").checked=true
}
function uncheck(){
document.getElementById("red").checked=false
}
</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">Blue<br>
<input type="radio" name="colors" id="green">Green
</form>
<button type="button" onclick="check()">Select "Red"</button>
<button type="button" onclick="uncheck()">Deselect "Red"</button>
</body>
</html>
Try it Yourself »
Radio Object Other Extensions