HTML DOM Radio sprawdzone nieruchomości
Definicja i Wykorzystanie
sprawdzone zestawy własności lub zwraca element jest zaznaczony.
gramatyka
Ustawianie sprawdzonych właściwościach:
radioObject.checked=true|false
Zwraca zaznaczone atrybuty:
radioObject.checked
Pomoc Browser
Wszystkie główne przeglądarki obsługują sprawdzone nieruchomości
Przykłady
Przykłady
Poniższy przykład przycisk opcji jest zaznaczona i nie wybrano:
<!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>
Spróbuj »
Radio Przedmioty