IE non mi permette di impostare un valore textarea con javascript
-
03-07-2019 - |
Domanda
Sto provando a cambiare value
su un elemento <textarea>
. Questo codice funziona alla grande in Firefox, ma IE afferma che c'è un errore onblur
e non imposta il valore.
<textarea
name="comment"
id="comment"
rows="8"
cols="80"
style="color:grey;"
onfocus="if(this.value=='Add a comment...') {this.style.color='black'; this.value='';}"
onblur="if(this.value=='') {this.style.color='grey'; this.value='Add a comment...';}">Add a comment...</textarea>
Cosa sto sbagliando?
Soluzione
Questo può causare il problema -
this.style.color = 'grigia'
this.style.color='gray';
Codice intero:
<textarea name="comment" id="comment" rows="8" cols="80" style="color: gray;" onfocus="if(this.value=='Add a comment...') {this.style.color='black'; this.value='';}"
onblur="if(this.value=='') {this.style.color='gray'; this.value='Add a comment...';}">Add a comment...</textarea>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow