title: a better way to swap values of text inputs?
body: <p>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:</p>
  
  <pre><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]);
              }
          });
      });
  });
  </code></pre>
  
  <p>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. </p>
  
  <p>error
  assignment to undeclared variable swapValues</p>
  
  <p>Is there a better way to do this?
  thx</p>