Hi

I have the following code in my head tags:

$(document).ready(function() {
        $('input[title]').each(function() {
                if($(this).val() === '') {
                        $(this).val($(this).attr('title'));
                }

                $(this).focus(function() {
                        if($(this).val() === $(this).attr('title')) {
                                $(this).val('').addClass('focused');
                        }
                });

                $(this).blur(function() {
                        if($(this).val() === '') {
                                
$(this).val($(this).attr('title')).removeClass('focused');
                        }
                });
        });
});

$(document).ready(function() {
        $('textarea[title]').each(function() {
                if($(this).val() === '') {
                        $(this).val($(this).attr('title'));
                }

                $(this).focus(function() {
                        if($(this).val() === $(this).attr('title')) {
                                $(this).val('').addClass('focused');
                        }
                });

                $(this).blur(function() {
                        if($(this).val() === '') {
                                
$(this).val($(this).attr('title')).removeClass('focused');
                        }
                });
        });
});

Obviously the first thing i need to do is combine these into one chunk
of code - I have no idea how to do this :/

Secondly, and more importantly, although this works perfectly on the
various text fields on the site, it wont update the colour of the
'text area' text on focus. It stays a light grey, when the CSS is:

.focused        {
        color: #000;
}

It populates the text area with the title text ok, it's just the
focussing that seems to break.

If anyone can shed some light on this I would be extremely grateful.
Something is making text areas behave differently to text fields

Thanks a lot in advance

James

Reply via email to