Created
June 26, 2009 19:41
-
-
Save tpitale/136687 to your computer and use it in GitHub Desktop.
jQuery clear on focus
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
;(function($) { | |
$.fn.clearfocus = function() { | |
return this.each(function() { | |
var $field = $(this); | |
var original_value = $field.val(); | |
$field.focus(function() { | |
if($field.val() == original_value) $field.val(""); | |
}); | |
$field.blur(function() { | |
if($field.val() == "") $field.val(original_value); | |
}); | |
}); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment