Textarea值=“值”不工作onload,但会onblur

时间:2010-05-07 10:22:07

标签: javascript html textarea

Here is my jsfiddle example,textarea显示没有值onload,但是onblur,textarea不接受value属性吗?

1 个答案:

答案 0 :(得分:5)

<强> Here is the solution :)

因为您使用的是textarea,所以它的值介于其标记名称之间:

<textarea class="jsf" name="msg" onblur="if(this.value=='') this.value='Write here!';" onfocus="if(this.value=='Write here!') this.value='';">Write here!</textarea>