jQuery<输入>聚焦时保留的水印输入>
我的表单上有一些 ,我想用字段标签为它们添加水印。已经有无数的水印插件,但据我所知,当
聚焦时,即使没有输入任何内容,它们都会清除水印。
理想情况下,我想要的是继续显示直到用户输入内容,无论是否集中。
有谁知道已经有一个插件可以做到这一点,或者知道可以帮助指导我的代码示例?
I have some <input>
s on my form, and I would like to watermark them with field labels. There are already myriad watermarking plugins, but best as I can tell they all clear the watermark when the <input>
is focused, even if there's nothing entered.
What I'd like, ideally, is something that would continue to display until the user typed something in, focused or not.
Does anyone know of a plugin that does this already, or know of a code sample that might help guide my way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此插件将在输入焦点时保留水印,尽管它会隐藏在任何 按键(甚至 Ctrl)。
This plugin will retain the watermark when the input is focused, although it will hide on any keypress (even Ctrl).
我为此创建了一个灵活的插件。它会进入状态:聚焦和填充,您可以定义自己的 css 来管理样式,例如可见性、颜色和...
检查 jQuery 的示例和完整文档此处占位符
I have created a flexible plugin for this purpose. it gets to state: focused and filled and you can define your own css to manage the style such as visibility, color and ...
check the samples and full doc for jQuery Placeholder here
作为另一种选择,如果您出于其他原因更喜欢其他插件之一,则更改脚本并不困难,以便水印在
keyup
上消失,而不是在focus
上消失>。As another alternative, if you like one of the other plugins better for other reasons, it wouldn't be very difficult to alter the script so that watermark disappears on
keyup
rather thanfocus
.