In questo semplicissimo tutorial jQuery imparerete come aggiungere un’autofill agli input presenti all’interno dei vostri form.
L’autofill viene utilizzato per guidare l’utente nella compilazione dei campi.
$(‘.autofill’)
.each(function(){
// Store the initial value of the input
$(this).data(‘value’,$(this).val());
})
.focus(function(){
// Remove the initial value, when user focus the input
if($(this).val()==$(this).data(‘value’)){
$(this).val(”);
}
})
.blur(function(){
// Insert the initial value if there’s no new value
if($.trim($(this).val())==”){
$(this).val($(this).data(‘value’));
}
});
fonte: www.sastgroup.com






