HTML DOM Sandi properti dibaca
Definisi dan Penggunaan
set properti dibaca atau kembali apakah kolom password read-only.
bidang read-only tidak dapat dimodifikasi. Namun, pengguna dapat memilih dan menyalin teks.
tatabahasa
Mengatur properti dibaca:
passwordObject.readOnly=true|false
atribut Kembali dibaca:
passwordObject.readOnly
Dukungan Browser
Semua browser utama mendukung properti dibaca
contoh
contoh
Berikut bidang contoh kode diatur untuk read-only:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi setResult () {
document.getElementById ( "pwd") ReadOnly = true .;
}
</ Script>
</ Kepala>
<Body>
<Form>
Password: <input type = "password" id = "pwd">
</ Form>
<Tombol type = "button" onclick = "setResult ()"> Set read-only </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi setResult () {
document.getElementById ( "pwd") ReadOnly = true .;
}
</ Script>
</ Kepala>
<Body>
<Form>
Password: <input type = "password" id = "pwd">
</ Form>
<Tombol type = "button" onclick = "setResult ()"> Set read-only </ button>
</ Body>
</ Html>
Coba »
Kata benda