Fiz essa função em jQuery baseado em um função que eu utilizava antigamente.
A vantagem dela é que funciona automaticamente para todos elementos de texto do site sem necessidade de ficar adicionando elemento por elemento.
/* Tratamento dos inputs dos formulários */
$('input:text').focus(function(){
if ($(this).val() == $(this)[0].defaultValue) {
$(this).val('');
}
});
$('input:text').focusout(function(){
if ($(this).val() == "" || $(this).val() == " ") {
var defVal = $(this)[0].defaultValue;
$(this).val(defVal);
}
});
Se você gostou desse post, leia também...
SOPA, PIPA e ACTA on January 19th, 2012
Teste app iPhone wordpress on January 3rd, 2011
Curiosidade - Horário UTC on September 10th, 2009
Como mudar a pasta Documents and Settings - Alterar o local on August 17th, 2009
Realidade Virtual - Lego Digital Box on April 6th, 2009
