Latest web development tutorials

HTML DOM Radio checked property

Radio Object Reference Radio Objects

Definition and Usage

checked property sets or returns a radio button is selected.

grammar

Setting checked properties:

radioObject.checked=true|false

Returns checked attributes:

radioObject.checked


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support checked property


Examples

Examples

The following example of a radio button is selected and not selected:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function check(){
    document.getElementById("red").checked=true
}
function uncheck(){
    document.getElementById("red").checked=false
}
</script>
</head>
<body>

<form>
你更喜欢哪种颜色?<br>
<input type="radio" name="colors" id="red">红色<br>
<input type="radio" name="colors" id="blue">蓝色<br>
<input type="radio" name="colors" id="green">绿色
</form>
<button type="button" onclick="check()">选择 "红色"</button>
<button type="button" onclick="uncheck()">不选择 "红色"</button>
    
</body>
</html>

try it"


Radio Object Reference Radio Objects