HTML DOM 라디오 속성을 확인
정의 및 사용
속성 세트를 선택 또는 라디오 버튼을 선택 반환합니다.
문법
선택 속성 설정 :
radioObject.checked=true|false
반환 속성을 확인 :
radioObject.checked
브라우저 지원
모든 주요 브라우저 선택 속성을 지원
예
예
라디오 버튼의 다음의 예는 선택되고 선택되지 않은 :
<!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>
<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>
»시도
라디오 개체