Jenis properti HTML DOM Radio
Definisi dan Penggunaan
Jenis properti mengembalikan tombol radio jenis bentuk elemen.
Untuk tombol radio, atribut selalu "radio".
tatabahasa
radioObject.type
Dukungan Browser
Semua browser utama mendukung atribut Jenis
contoh
contoh
Contoh berikut mengembalikan jenis radio berupa tombol elemen:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
var x = document.getElementById ( "red") ketik .;
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 = "blue"> Biru Situs
<Input type = "radio" name = "warna" id = "green"> green
</ Form>
<Tombol type = "button" onclick = "displayResult ()"> jenis input Tampilan </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
var x = document.getElementById ( "red") ketik .;
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 = "blue"> Biru Situs
<Input type = "radio" name = "warna" id = "green"> green
</ Form>
<Tombol type = "button" onclick = "displayResult ()"> jenis input Tampilan </ button>
</ Body>
</ Html>
Coba »
Objek radio