Posted By

chrisaiv on 10/01/09


Tagged

jquery


Versions (?)

jQuery: Swap Text within Text Inputs


 / Published in: jQuery
 

  1. swapValues = [];
  2. $(".text_input_values").each(function(i){
  3. swapValues[i] = $(this).val();
  4. $(this).focus(function(){
  5. if ($(this).val() == swapValues[i]) {
  6. $(this).val("");
  7. }
  8. }).blur(function(){
  9. if ($.trim($(this).val()) == "") {
  10. $(this).val(swapValues[i]);
  11. }
  12. });
  13. });

Report this snippet  

You need to login to post a comment.