HTML DOM Checkbox diperiksa properti
Definisi dan Penggunaan
diperiksa set properti atau kembali apakah kotak centang harus diperiksa.
tatabahasa
Pengaturan properti diperiksa:
checkboxObject.checked=true|false
Pengembalian memeriksa atribut:
checkboxObject.checked
Dukungan Browser
Semua browser utama mendukung properti diperiksa
contoh
contoh
Contoh berikut menetapkan status kotak centang:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi cek () {
document.getElementById ( "Check1"). diperiksa = true
}
Fungsi hapus centang () {
document.getElementById ( "Check1"). diperiksa = false
}
</ Script>
</ Kepala>
<Body>
<Form>
<Input type = "checkbox" id = "Check1"> Anda seperti musim panas?
</ Form>
<Tombol onclick = "cek ()"> untuk mengkonfirmasi kotak pilihan </ button>
<Tombol onclick = "hapus centang ()"> tidak mengkonfirmasi kotak pilihan </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi cek () {
document.getElementById ( "Check1"). diperiksa = true
}
Fungsi hapus centang () {
document.getElementById ( "Check1"). diperiksa = false
}
</ Script>
</ Kepala>
<Body>
<Form>
<Input type = "checkbox" id = "Check1"> Anda seperti musim panas?
</ Form>
<Tombol onclick = "cek ()"> untuk mengkonfirmasi kotak pilihan </ button>
<Tombol onclick = "hapus centang ()"> tidak mengkonfirmasi kotak pilihan </ button>
</ Body>
</ Html>
Coba »
contoh yang lebih
Checkbox - teks dikonversi ke huruf besar
Sebuah bentuk beberapa kotak centang
benda kotak centang