Properti HTML DOM Checkbox defaultChecked
Definisi dan Penggunaan
properti defaultChecked mengembalikan nilai default untuk properti diperiksa.
Properti ini mengembalikan true jika kotak centang dipilih secara default, jika tidak maka kembali palsu.
tatabahasa
checkboxObject.defaultChecked
Dukungan Browser
Semua browser utama mendukung properti defaultChecked
contoh
contoh
Contoh berikut mengembalikan nilai properti diperiksa:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
var x = document.getElementById ( "myCheck") defaultChecked .;
alert (x);
}
</ Script>
</ Kepala>
<Body>
<Form>
<Input type = "checkbox" id = "myCheck" diperiksa = "diperiksa"> Anda seperti musim panas?
</ Form>
<Tombol type = "button" onclick = "displayResult ()"> pilih kotak pilihan bawaan lakukan? </ Tombol>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
var x = document.getElementById ( "myCheck") defaultChecked .;
alert (x);
}
</ Script>
</ Kepala>
<Body>
<Form>
<Input type = "checkbox" id = "myCheck" diperiksa = "diperiksa"> Anda seperti musim panas?
</ Form>
<Tombol type = "button" onclick = "displayResult ()"> pilih kotak pilihan bawaan lakukan? </ Tombol>
</ Body>
</ Html>
Coba »
benda kotak centang