admin 管理员组文章数量: 1086019
So, for instance facebook's search bar has faint word that says "search", but when you click on the bar, it bees blank and you may begin typing, when you click away the "search" goes back.
Similarly, SO's ask a question title box has faint words that go away when you start typing.
I'm not too sure what this effect is called, but I'm wondering if theres a jQuery plugin that helps to achieve this. This isn't particularly difficult to program, but I thought why reinvent the wheel if someone already made a plugin for it.
So, for instance facebook's search bar has faint word that says "search", but when you click on the bar, it bees blank and you may begin typing, when you click away the "search" goes back.
Similarly, SO's ask a question title box has faint words that go away when you start typing.
I'm not too sure what this effect is called, but I'm wondering if theres a jQuery plugin that helps to achieve this. This isn't particularly difficult to program, but I thought why reinvent the wheel if someone already made a plugin for it.
Share Improve this question asked Jan 4, 2011 at 1:44 Razor StormRazor Storm 12.3k20 gold badges95 silver badges151 bronze badges2 Answers
Reset to default 9I made a jQuery plugin that does just that!
Update
I've since moved it to GitHub and rewrote it to address some issues. Enjoy! Feel free to email me where you use it, so I can feel useful :)
HTML5 has a feature called "placeholder" that achieves this. For example:
<input name="search" placeholder="Search" />
Of course, HTML5 isn't supported by all browsers, so javascript would do the trick elsewhere.
本文标签: javascriptHow do I make faint words in search bar that go away when you clicktypeStack Overflow
版权声明:本文标题:javascript - How do I make faint words in search bar that go away when you clicktype? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744011468a2518229.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论