SO Help: Place holder not working in textarea

http://stackoverflow.com/questions/18735863/place-holder-not-working-in-textarea

by SpYk3

HTML

<textarea id="a" placeholder="text are text?"></textarea>
<input id="b" placeholder="input text" />

JavaScript

$(document).on('blur focus', '[placeholder]', function(e) {
    var val = $.trim($(this).val() || $(this).text()),
        placeHolder = $(this).prop('placeholder');
    
    switch(e.type) {
        case 'focusin':
            $(this).css('color', '');
            if (val == placeHolder) $(this).val('').text('');
            break;
        case 'focusout':
            if (val == '') $(this).val(placeHolder).text(placeHolder).css('color', '#A9A9A9');
            break;
    }
});

//    the following will make sure all fields having placeholder will start with placeholder in place
$('[placeholder]').each(function(i) { $(this).text($(this).prop('placeholder')); }).css('color', '#A9A9A9');