我有一个输入字段,您可以在其中输入一些文本。它有一些默认文本:
<input type="text" id="text" value="Type some text here" maxlength="35" tabindex="10">
我想让默认文本在用户点击默认文本或在输入字段内时消失。
我该怎么做?
最佳答案
尝试使用占位符属性(placeholder="Your Text"而不是 value="Your Text"):
<input type="text" id="text" maxlength="35" tabindex="10" placeholder="Type some text here">
注意:Placeholder 属性在 IE8/9 或 Opera Mini 中不起作用 (http://caniuse.com/#feat=input-placeholder)。
关于html - 你如何让输入的文字消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28501329/