如何制作一个像在 iCloud 上看到的输入字段?
我希望占位符一直保留到有人开始输入为止。有没有办法用 jQuery 来完成这个?
最佳答案
您可能指的是水印功能。
A watermark typically appears as light gray text within an input or textarea element whenever the element is empty and does not have focus. This provides a hint to the user as to what the input or textarea element is used for, or the type of input that is required.
(来源:googlecode.com)
如果是这种情况,您可能想尝试 jquery-watermark 强>。它支持HTML5 "placeholder" native 功能(在支持它的浏览器中)并在其他/旧版本中优雅地降级。
注意:存在许多其他插件。 Googling 'jquery watermark'或 'jquery placeholder'将帮助您找到它们:)
注意 2:为了尽可能兼容,Apple 不依赖 HTML5 占位符属性,而只是利用 JQuery 在用户开始输入。
关于jquery - icloud.com 喜欢表单输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8880090/