Posted By

muzafarova on 04/01/11


Tagged

js jquery


Versions (?)

Onblur/onfocus


 / Published in: jQuery
 

  1. var automessages = [];
  2. $(function(){
  3. $('.automessage').each(function(){
  4. automessages[$(this).attr('id')] = $(this).val();
  5. }).focus(function(){
  6. if ($(this).val() == automessages[$(this).attr('id')]) { $(this).val('') }
  7. }).blur(function(){
  8. if ($(this).val() == '') { $(this).val(automessages[$(this).attr('id')]) }
  9. });
  10. });

Report this snippet  

You need to login to post a comment.