2009-04-30 8 views
0

Ich versuche, die value auf einem <textarea> Element zu ändern. Dieser Code funktioniert gut in Firefox, aber IE behauptet, es gibt einen Fehler onblur und legt den Wert nicht fest.IE nicht lassen Sie einen Textarea Wert mit 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> 

Was mache ich falsch?

Antwort

2

Kann dies das Problem verursachen -

this.style.color 'grau' =

?

this.style.color='gray'; 

Whole-Code:

<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

wahrscheinlich die meisten, sie sind amerikanische Farbnamen;) –

+1

Yep - Die amerikanische COLOR Namen :) – Kirtan

Verwandte Themen