0

链接示例在这里:http: //jsfiddle.net/fxr5p/如果值为空,如何使onload工作onblur功能?show type your keyword,然后点击输入部分,onblur单词消失?谢谢。

<input type="text" value=""  id="search" name="Search" onblur="if(this.value=='') this.value='type your keyword';" onfocus="if(this.value=='type your keyword') this.value='';">
4

3 回答 3

0
<script>
  document.body.onload = function ()
  {
    document.getElementById("search").value = "type your keyword";
  }
</script>
于 2011-06-08T19:21:44.073 回答
0

尝试这个:

<input type="text" value="type your keyword"  id="search" name="Search" onblur="if(this.value=='') this.value='type your keyword';" onfocus="if(this.value=='type your keyword') this.value='';">
于 2011-06-08T19:23:24.127 回答
0

我想你快到了,只需使用value="type your keyword".

于 2011-06-08T19:23:26.107 回答