It would be interesting to try this with the html5 attribute placeholder. This will work in all current versions of Safari, Chrome and Firefox.
<input type="text" name="s" id="search" placeholder="Search for post"/>
Then you need to add backup code for browsers that do not support this feature.
$(function() {
$(':input[placeholder]').each(function() {
var me = $(this);
me.val(me.attr('placeholder'))
.focus(function() {
var that = $(this);
if (that.val() == that.attr('placeholder')) {
that.val('');
}
}).blur(function() {
var that = $(this);
if (that.val().trim().length == 0) {
that.val(that.attr('placeholder'));
}
});
});
});
jsfiddle, . , , , , , , IE 6.
http://jsfiddle.net/V2R9J/ (: trim , . .)
: , ajax. - live, . , password, * - , .
, , , , , html5, , .