I have tried to make a jQuery code to delete the value of my (email) input field when clicked, and when unclicked (.blur()) the value (same as before) should return to the input field, unless something else is written. It works when I click the input field, the text disappears and comes back when I click away, but when i write something and deletes it, the value/text from before doesn't come back.. Heres my code, applied to a simple input type="email"
$(document).ready(function() {
var default_email = 'Skriv din email her..';
$('input[type="email"]').attr('value', default_email).focus(function() {
if ( $ (this).val() == default_email) {
$(this).attr('value', '');
}
}).blur(function() {
if($(this).val() == '') {
$(this).attr('value', default_email);
};
});
});