I use this code to switch the values โโof my onFocus and Blur inputs:
$('input, textarea').focus(function() {
value=$(this).val();
$(this).attr("value","")};
});
$('input, textarea').blur(function() {
if($(this).val()=="") {
$(this).val(value);
}
});
The only problem is that when I enter something into these inputs, redefine after entering into another field, the field becomes empty. Is there a way to edit this code to ban it?
An example for you here :)
I tried something like this, but this was not what I want:
$('input, textarea').focus(function() {
value=$(this).val();
if($(this).val(value)) {
$(this).attr("value","");
});
$('input, textarea').blur(function() {
if($(this).val()=="") {
$(this).val(value);
}
});
source
share