Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   var $formulario = $('#formulario_terminado');
  2.   $formulario.find('input[type="text"]').each(function() {
  3.     $(this).data('valor-original', this.value);
  4.   });
  5.  
  6.   $formulario.on('focus', 'input[type="text"]', function() {
  7.     var $this = $(this);
  8.     if ($this.val() === $this.data('valor-original')) {
  9.       $this.val('');
  10.     }
  11.   });
  12.  
  13.   $formulario.on('blur', 'input[type="text"]', function() {
  14.     var $this = $(this);
  15.     if ($this.val().trim() === '') {
  16.       $this.val($this.data('valor-original'));
  17.     }
  18.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement