Latest web development tutorials

HTML DOM Radio diperiksa properti

Radio Object Reference Objek radio

Definisi dan Penggunaan

diperiksa set properti atau mengembalikan tombol radio dipilih.

tatabahasa

Pengaturan properti diperiksa:

radioObject.checked=true|false

Pengembalian memeriksa atribut:

radioObject.checked


Dukungan Browser

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Semua browser utama mendukung properti diperiksa


contoh

contoh

Contoh berikut dari tombol radio dipilih dan tidak dipilih:

<!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>

Coba »


Radio Object Reference Objek radio