Properti HTML DOM Radio defaultChecked
Definisi dan Penggunaan
properti defaultChecked mengembalikan nilai default untuk properti diperiksa.
Jika tombol radio default dipilih, itu mengembalikan nilai true, jika tidak fasle.
tatabahasa
radioObject.defaultChecked
Dukungan Browser
Semua browser utama mendukung properti defaultChecked
contoh
contoh
Deteksi "Blue" opsi yang dipilih secara default:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
var x = document.getElementById ( "biru") defaultChecked .;
alert (x);
}
</ Script>
</ Kepala>
<Body>
<Form>
warna yang Anda sukai? <br>
<Input type = "radio" name = "warna" id = "red"> red Situs
<Input type = "radio" name = "warna" id = "biru" diperiksa = "diperiksa"> Biru Situs
<Input type = "radio" name = "warna" id = "green"> green
</ Form>
<Tombol type = "button" onclick = "displayResult ()"> pilih default biru itu? </ Tombol>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
var x = document.getElementById ( "biru") defaultChecked .;
alert (x);
}
</ Script>
</ Kepala>
<Body>
<Form>
warna yang Anda sukai? <br>
<Input type = "radio" name = "warna" id = "red"> red Situs
<Input type = "radio" name = "warna" id = "biru" diperiksa = "diperiksa"> Biru Situs
<Input type = "radio" name = "warna" id = "green"> green
</ Form>
<Tombol type = "button" onclick = "displayResult ()"> pilih default biru itu? </ Tombol>
</ Body>
</ Html>
Coba »
Objek radio