HTML DOM Radio comprueba la propiedad
Definición y Uso
comprobado conjuntos de propiedades o devuelve se selecciona un botón de radio.
gramática
Configuración de las propiedades controladas:
radioObject.checked=true|false
Rendimientos comprobados atributos:
radioObject.checked
Soporte para el navegador
Todos los principales navegadores soportan característica sea comprobada
Ejemplos
Ejemplos
El siguiente ejemplo de un botón de radio está seleccionado y no seleccionado:
<!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>
Trate »
Objetos de radio