I have an email sign up and search box that have the label inside the box, IE the email box says "sign up" inside the input. When you click in the box the value is removed allowing you to enter your email, if you enter nothing and click out, the "sign up" re appears. I am using the following code:
$(function() {
swapValues = [];
$(".swap_value").each(function(i){
swapValues[i] = $(this).val();
$(this).focus(function(){
if ($(this).val() == swapValues[i]) {
$(this).val("");
}
}).blur(function(){
if ($.trim($(this).val()) == "") {
$(this).val(swapValues[i]);
}
});
});
});
However, I get the following error in console and am possibly having issues with other scripts due to this. Ill know for sure when I finish debugging.
error assignment to undeclared variable swapValues
Is there a better way to do this? thx