Created
January 23, 2009 11:26
-
-
Save carlosbrando/50978 to your computer and use it in GitHub Desktop.
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.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