Return to Snippet

Revision: 22682
at January 19, 2010 08:38 by flicity


Initial Code
autoFill($("targetElement"), "content");

//auto fill search field
function autoFill(id, v){
    $(id).attr({
        value: v
    }).focus(function(){
        if($(this).val()==v){
            $(this).val("").css({
                color: "#333"
            });
        }
    }).blur(function(){
        if($(this).val()==""){
            $(this).val(v);
        }
    });

}

Initial URL
http://www.joesak.com/2008/11/19/a-jquery-function-to-auto-fill-input-fields-and-clear-them-on-click/

Initial Description
add a value to your text input e.g. "Enter keywords" and clear on-click

Initial Title
autofill and clear text input

Initial Tags
search, jquery

Initial Language
jQuery