Clear default input text on focus

Clears and restores only default text, assign the input element a class of default

$('.default').each(function() {
    var default_value = this.value;
    $(this).focus(function() {
        if(this.value == default_value) {
            this.value = '';
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            this.value = default_value;
        }
    });
});
Posted by Tom at 00:00

Post a comment

Authors

Tags