答案 0 :(得分:29)
答案 1 :(得分:3)
答案 2 :(得分:3)
答案 3 :(得分:2)
或者,如果您希望无论输入什么文本都将其更改回默认值...
<input ...
onfocus="if (this.value==this.defaultValue) this.value = ''"
onblur="if (this.value!=this.defaultValue) this.value = this.defaultValue" />
答案 4 :(得分:0)
试试这个。也许它可以帮到你:
<form action="/search" method="get">
<input type="text" name="q" value="Search..." onfocus="if (this.value == 'Search...') (this.value='')" onblur="if (this.value == '') (this.value='Search...')" />