IE not letting me set a textarea value with javascript
-
03-07-2019 - |
Question
I'm trying to change the value
on a <textarea>
element. This code works great in Firefox, but IE claims there's an error onblur
and doesn't set the value.
<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>
What am I doing wrong?
Solution
Can this be causing the problem -
this.style.color='grey'
?
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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow