Tipo di pulsante Proprietà
Esempio
Restituisce il tipo di un pulsante:
var x = document.getElementById("myBtn").type;
Definizione e utilizzo
La proprietà type imposta o restituisce il tipo di un pulsante.
Suggerimento: specificare sempre l'attributo type per il pulsante. Il tipo predefinito per Internet Explorer è "pulsante", mentre in altri browser (e nella specifica W3C) è "invia".
Supporto browser
Property | |||||
---|---|---|---|---|---|
type | Yes | Yes | Yes | Yes | Yes |
Sintassi
Restituisce la proprietà del tipo:
buttonObject.type
Imposta la proprietà del tipo:
buttonObject.type = "submit|button|reset"
Valori di proprietà
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) |
Dettagli tecnici
Valore di ritorno: | Una stringa, che rappresenta il tipo di pulsante |
---|
Altri esempi
Esempio
Cambia il tipo di pulsante in "invia":
document.getElementById("myBtn").type = "submit";
Esempio
Cambia il tipo di pulsante in "reset":
document.getElementById("myBtn").type = "reset";
Pagine correlate
Riferimento HTML: attributo di tipo HTML <pulsante>
❮ Oggetto pulsante