You can use the solution described in link
Using a function called placeholder()
:
function placeholder(str){
$('input').css('color','#ccc');
$('input').val(str);
}
You should run it once when you load your page:
placeholder("Digite o produto desejado...");
And you should assign these events to your input, which would be ao clicar nele
(click) clear the value of it, and ao sair dele
(blur) put the placeholder again.
$('input').on("click", function () {
var ValorAnterior = $.cookie("ValorAtual") || "";
$(this).val(ValorAnterior);
});
$('input').on("blur", function () {
$.cookie("ValorAtual", $(this).val());
placeholder("Digite o produto desejado...");
});
However you have to include the jQuery Cookie plugin (if you wish to use another form of cookie, / p>