Return to Snippet

Revision: 29461
at March 14, 2013 23:11 by cryothic


Updated Code
<input type="text" value="Name" rel="Name" class="replace" />

$(".replace")
    .focus(function(){
        if ($(this).val() === $(this).attr("rel")) {
            $(this).val("").css("color", "#000000");
        }
    })
    .blur(function(){
        if ($(this).val() === "") {
            $(this).val($(this).attr("rel")).css("color", "#5e6a72");
        }
    });

Revision: 29460
at July 29, 2010 22:57 by cryothic


Initial Code
<input type="text" value="Name" rel="Name" />

$(".replace")
    .focus(function(){
        if ($(this).val() === $(this).attr("rel")) {
            $(this).val("").css("color", "#000000");
        }
    })
    .blur(function(){
        if ($(this).val() === "") {
            $(this).val($(this).attr("rel")).css("color", "#5e6a72");
        }
    });

Initial URL

                                

Initial Description
Replaces the pre-defined text of a textbox (e.g. the purpose of the textbox) when the textbox gets focussed, and resets the text if it blurs when empty

Initial Title
Textbox inside-label replace

Initial Tags
replace

Initial Language
jQuery