Created
October 28, 2009 18:44
-
-
Save marciobarrios/220694 to your computer and use it in GitHub Desktop.
para autolimpiar inputs/textarea (podria hacer que con una clase se ejecutara automáticamente)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//plugin para aplicar en textarea/inputs para que cuando tenga el foco se elimine el contenido | |
$.fn.autoClean = function() { | |
return this.filter('input, textarea').each(function(){ | |
var $this = $(this); | |
$this | |
.attr('default',$this.val()) | |
.focus(function(){ | |
if ( $this.attr('id') == 'terms' ) { | |
if ($this.val() == $this.attr('title') ) $this.val(''); | |
} else { | |
if ($this.val() == $this.attr('default') ) $this.val(''); | |
} | |
}) | |
.blur(function(){ | |
if ($this.val() == '') $this.val($this.attr('default')); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment