2009-04-30 6 views
0

J'essaye de changer le value sur un élément <textarea>. Ce code fonctionne très bien dans Firefox, mais IE prétend qu'il y a une erreur onblur et ne définit pas la valeur.IE ne pas me laisser définir une valeur de textarea avec 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> 

Qu'est-ce que je fais mal?

Répondre

2

Cela peut-il être à l'origine du problème -

this.style.color = 'gris'

?

this.style.color='gray'; 

code entier:

<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

Très probablement, ils sont des noms de couleurs américaines;) –

+1

Yep - Les noms américains de COULEUR :) – Kirtan

Questions connexes