How to make weak words in the search bar that disappear when pressed / type?

So, for example, in the facebook search bar there is a weak word that says “search”, but when you click on the panel, it becomes empty, and you can start typing when you click “search”, it returns.

Similarly, a SO ask question title field has weak words that disappear when you start typing.

I'm not too sure what this effect is called, but I wonder if there is a jQuery plugin in it that helps achieve this. It is not particularly difficult to program, but I thought why reinvent the wheel if someone had already made a plug-in for it.

+5
source share
2 answers

I created a jQuery plugin that does just that!

Update

Since then, I transferred it to GitHub and rewrote it to solve some problems. Enjoy it! Feel free to email me where you use it, so I can feel useful :)

+9
source

HTML5 has a "placeholder" function that accomplishes this. For instance:

<input name="search" placeholder="Search" />

Of course, HTML5 is not supported by all browsers, so javascript will do the trick elsewhere.

+5
source

All Articles