Properti jenis tombol
Contoh
Kembalikan jenis tombol:
var x = document.getElementById("myBtn").type;
Definisi dan Penggunaan
Properti tipe mengatur atau mengembalikan tipe tombol.
Tip: Selalu tentukan atribut type untuk tombol. Jenis default untuk Internet Explorer adalah "button", sedangkan di browser lain (dan dalam spesifikasi W3C) adalah "submit".
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
type | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti tipe:
buttonObject.type
Setel properti tipe:
buttonObject.type = "submit|button|reset"
Nilai properti
Value | Description |
---|---|
submit | The button is a submit button (this is default for all browsers, except Internet Explorer) |
button | The button is a clickable button (this is default for Internet Explorer) |
reset | The button is a reset button (clears form data) |
Detail Teknis
Nilai Kembali: | Sebuah String, mewakili jenis tombol |
---|
Lebih Banyak Contoh
Contoh
Ubah jenis tombol menjadi "kirim":
document.getElementById("myBtn").type = "submit";
Contoh
Ubah jenis tombol menjadi "reset":
document.getElementById("myBtn").type = "reset";
Halaman Terkait
Referensi HTML: Atribut tipe <button> HTML
Objek Tombol