Skip to content

Instantly share code, notes, and snippets.

@carlosbrando
Created January 23, 2009 11:26
Show Gist options
  • Save carlosbrando/50978 to your computer and use it in GitHub Desktop.
Save carlosbrando/50978 to your computer and use it in GitHub Desktop.
(function($){
$.fn.defaultValueActsAsHint = function() {
return this.each(function() {
$(this).attr('_default', $(this).attr('value'))
$(this).addClass('hint');
$(this).bind('focus', function(event) {
if ($(this).attr('_default') == $(this).attr('value'))
$(this).removeClass('hint').attr('value', '');
});
$(this).blur(function() {
if ($.trim($(this).attr('value')) == '')
$(this).addClass('hint').attr('value', $(this).attr('_default'));
});
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment