如何格式化 html 表单字段中显示的提示?
之前有一个关于如何在文本字段(html 表单字段)中显示提示的问题,当用户单击正在考虑的字段时,提示会自动清除。例如,当字段获得焦点时,表单内显示的提示将被清除,而用户无需手动删除字符。
给出的解决方案(并且它工作完美)-
<input onfocus="if (this.value=='search') this.value = ''" type="text" value="search">
现在我的问题是,如何格式化显示为提示的文本(在本例中为“搜索”)。通过格式化,我希望它具有某种颜色和字体类型。
我可以通过使用 css- 对其他没有预加载提示的字段执行此操作 颜色:#123123;字体系列:calibri;
谢谢!
There was a question previously on how to show hints in a text field (html form field), which clears automatically when the user clicks on the field under consideration. As in, when the field gets focus, the hint displayed inside the form gets cleared without the user having to manually delete the characters.
The solution given (and it works perfectly) -
<input onfocus="if (this.value=='search') this.value = ''" type="text" value="search">
Now my question is, how do you format the text that is displayed as the hint (in this case "search"). By formatting, i would want it to be in a certain color and font type.
I can do this to the other fields, which do not have this preloaded hint in it, by using css-
color:#123123; font-family:calibri;
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您询问的是如何设置
input
元素的内容(值)的样式。您可以为此使用常规 CSS:
工作示例: http://jsfiddle.net/fxxp4/
You're asking about styling the content (value) of an
input
element.You can use regular CSS for this:
Working example: http://jsfiddle.net/fxxp4/