Skip to content

Instantly share code, notes, and snippets.

@gopperman
Forked from anonymous/gist:5967714
Created July 10, 2013 16:19

Revisions

  1. @invalid-email-address Anonymous created this gist Jul 10, 2013.
    15 changes: 15 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    jQuery(document).ready(function() {
    jQuery.fn.cleardefault = function() {
    return this.focus(function() {
    if( this.value == this.defaultValue ) {
    this.value = "";
    }
    }).blur(function() {
    if( !this.value.length ) {
    this.value = this.defaultValue;
    }
    });
    };
    jQuery("input, textarea").cleardefault();

    });