Return to Snippet

Revision: 28454
at July 8, 2010 17:29 by omerta83


Initial Code
(function($){  
    $.fn.clearDefault = function(){  
        return this.each(function(){  
            var default_value = $(this).val();  
            $(this).focus(function(){  
                if ($(this).val() == default_value)  
                              $(this).val("");  
            });  
            $(this).blur(function(){  
                if ($(this).val() == "")  
                              $(this).val(default_value);  
            });  
        });  
    };  
})(jQuery);  
  
// How to use it: $('input').clearDefault();

Initial URL

                                

Initial Description

                                

Initial Title
One-click clearing of default input text values

Initial Tags
javascript, jquery

Initial Language
JavaScript