Return to Snippet

Revision: 42939
at March 13, 2011 11:51 by slav123


Initial Code
$('.default-value').each(function() {
    var default_value = this.value;
    $(this).css('color', '#666'); // this could be in the style sheet instead
    $(this).focus(function() {
        if(this.value == default_value) {
            this.value = '';
            $(this).css('color', '#333');
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            $(this).css('color', '#666');
            this.value = default_value;
        }
    });
});

Initial URL


Initial Description


Initial Title
jQuery default value

Initial Tags


Initial Language
JavaScript