本文介绍了HTML输入字段提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想向用户提供他需要输入到我的文本字段中的提示。但是,当我设置该值时,一旦用户单击文本字段,该值就不会消失。如何让它消失?
I want to provide the user with a hint on what he needs to enter into my text field. However, when I set the value, it does not disappear once a user clicks on the text field. How can you make it disappear?
<form action="input_password.htm">
<p>Username:<br><input name="Username" value="Enter username.." type="text" size="20" maxlength="20"></p>
</form>
推荐答案
您需要附加 onFocus
事件通过Javascript输入字段:
You'd need attach an onFocus
event to the input field via Javascript:
<input type="text" onfocus="this.value=''" value="..." ... />
这篇关于HTML输入字段提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!