2009-04-30 5 views
0

<textarea>エレメントのvalueを変更しようとしています。このコードはFirefoxでうまくいきますが、IEにはエラーonblurがあり、値は設定されていません。JavaScriptでテキストエリアの値を設定させないようにしました

<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> 

私は間違っていますか?

答えて

2

は、この問題を引き起こしていることができます -

this.style.color = 'グレー'

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> 
+0

ほとんどの場合、彼らはアメリカの色の名前です;) –

+1

うん - そのアメリカCOLOR名:) – Kirtan

関連する問題