views:

53

answers:

3

i want to put some description text in light grey in a text field. then when a user clicks on it the text disappears and he can type whatever he wants.

is there a jquery plugin for this? i dont know what to search for in google.

+2  A: 

Yes -- what you want is relatively simple to do. Check out the following link:

JQuery Watermark

George
A: 
$(document).ready(function() {
    $('#IDofTextField').css({'color': '#aaaaaa', 'font-style': 'italic'});
    $('#IDofTextField').attr('value', 'Your text in here');
    $('#IDofTextField').focus(function() {
        $('#IDofTextField').css({'color': '#000', 'font-style': 'normal'});
        $('#IDofTextField').attr('value', '');
    });
    $('#IDofTextField').blur(function() {
        if ($('#IDofTextField').val() == '') {
            $('#IDofTextField').css({'color': '#aaaaaa', 'font-style': 'italic'});
            $('#IDofTextField').attr('value', 'Your text in here');
        }
    });
});
harpax