IEでjavascriptを使用してtextarea値を設定できない
-
03-07-2019 - |
質問
value
要素の<textarea>
を変更しようとしています。このコードはFirefoxでうまく機能しますが、IEはエラーonblur
があると主張し、値を設定しません。
<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>
何が間違っているのですか?
解決
これが問題を引き起こしている可能性がありますか-
this.style.color = 'grey'
?
this.style.color='gray';
全コード:
<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>
所属していません StackOverflow