carlosbrando (owner)

Revisions

gist: 50978 Download_button fork
public
Public Clone URL: git://gist.github.com/50978.git
Embed All Files: show embed
jquery.defaultvalueactsashint.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(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);