i have a number of input fields throughout my page, each with a description as its value.
ex:
i am trying to get jQuery to remove this description from the input field on focus, and then replace it on blur if no other content was entered.
i am extremely unfamiliar with jQuery and what i came up with doesnt work at all, this is what i have
note: i want this to work for all input fields anywhere on the site, as i dont want to use labels for my forms.
does anyone have a better way of doing this, or did i mess up with syntax or something?
thanks.
ex:
HTML:
<input type="text" value="DESC" />
i am trying to get jQuery to remove this description from the input field on focus, and then replace it on blur if no other content was entered.
i am extremely unfamiliar with jQuery and what i came up with doesnt work at all, this is what i have
Code:
$(document).ready(function() {
$('input').focus(function() {
var value=$(this).val();
$(this).val("");
});
$('input').blur(function() {
if($(this).val()=="") {
$(this).val(value);
}
});
});
note: i want this to work for all input fields anywhere on the site, as i dont want to use labels for my forms.
does anyone have a better way of doing this, or did i mess up with syntax or something?
thanks.