问题描述
使文本输入字段以灰色显示在该字段中输入内容的说明的最佳方法是什么.当您专注于该输入字段时,灰色的说明文本消失,而您的输入文本显示为黑色.如果您擦除输入文本并将焦点移到该输入之外,则说明灰色文本会再次出现.
What's the best way to have a text input field that displays instructions of what to enter in that field in gray. When you focus on that input field, the gray instruction text disappears and your input text appears black. If you erase your input text and focus away from that input, then the instruction gray text reappears.
我尝试使用jQuery实现此功能,但是使用不同的浏览器会遇到各种奇怪的问题.有时,当您返回屏幕时,说明文本变为黑色并且不再消失,诸如此类的问题.
I've tried implementing this with jQuery, but I get all kinds of weird issues with different browsers. Sometimes when you go back a screen, the instruction text becomes black and no longer disappears, issues like that.
是否有用于此目的的标准javascript库?我找不到任何东西!
Is there a standard javascript library for this? I can't find any!
哦,指令文本不能是图像,因为根据浏览器的语言偏好,它必须以不同的语言提供.
Oh, and the instruction text can't be an image because it has to be available in different languages depending on the browser's language preference.
推荐答案
您可以在jquery中使用水印插件.请使用此链接.
You can use watermark plugin in jquery.use this link.
示例
$(this).Watermark("your instructions");
这篇关于显示指令(占位符)文本的Javascript文本输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!