jQuery: Swap Text within Text Inputs


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.