質問

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>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top