How can I make this in JQuery? I need it to show the keyword if there is text in the value input.
Asked
Active
Viewed 102 times
-3
-
You want to make a picture with jquery, right? You have to elaborate a little more... – A. Wolff Apr 27 '13 at 17:38
-
No... easier to describe – Stefan Frederiksen Apr 27 '13 at 17:52
-
not for a blind person – A. Wolff Apr 27 '13 at 17:55
-
If you do not care about supporting IE 8 or 9 you can use the HTML 5 `placeholder` attribute. If you do want to support IE 8 and 9 then you can use [modernizr](http://modernizr.com/) combined with [yepnope.js](http://yepnopejs.com/) to conditionally load a polyfill (such as [this](https://github.com/ginader/HTML5-placeholder-polyfill)) to enable support for older browsers (such as IE 8 and 9). – War10ck Apr 27 '13 at 18:00
2 Answers
2
Provided you're fine with not supporting 30% of the market (it's a HTML5 feature not supported in some legacy browsers) you can simply use
<input value="" placeholder="Your placeholder text">
or otherwise add this jquery plugin to make it work everywhere.

David Mulder
- 26,123
- 9
- 51
- 114
-
-
Yeah, that's why I added the note about the jQuery plugin and additionally it is often seen graceful degradation, as not seeing the placeholder text only makes it less beautiful whilst not losing any functionality. – David Mulder Apr 27 '13 at 18:23
0
Have you tried using placeholder text?
<form>
<input name="q" placeholder="Search uploads">
<input type="submit" value="Search">
</form>

Adam Pearce
- 9,243
- 2
- 38
- 35
-
-
So look here, seems like the best jquery plugin for that: http://stackoverflow.com/a/13281620/1414562 "Also it doesn't submit the placeholder text as a value when you submit your form " – A. Wolff Apr 27 '13 at 17:57