jQuery <input> watermark that stays when focused
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 an开发者_Go百科yone know of a plugin that does this already, or know of a code sample that might help guide my way?
This plugin will retain the watermark when the input is focused, although it will hide on any keypress (even Ctrl).
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
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 than focus
.
精彩评论