当有人输入文本输入时如何删除提示 - javascript

ome*_*erk 0 javascript jquery input

我有一个这个文本输入

<input id="searchInput" type="text" value="Search Here" />
Run Code Online (Sandbox Code Playgroud)

我想删除输入的值,即'在这里搜索',因为有人输入内容...如何在jQuery或javascript中执行此操作?

Nin*_*Nye 5

只需使用占位符文本

<input id="searchInput" type="text" placeholder="Search Here" />
Run Code Online (Sandbox Code Playgroud)

http://www.w3.org/TR/html5/forms.html#the-placeholder-attribute

  • 请_don't_链接到http://www.w3fools.com,请参阅http://meta.stackexchange.com/questions/120025/will-i-be-downvoted-for-giving-a-w3schools-link.以下是官方资源:http://www.w3.org/TR/html5/forms.html#the-placeholder-attribute (2认同)