JSFiddle - React, Tailwind, and code Playground
by George Berkeley
HTML
<input type="text" class="hasPlaceholder" placeholder="Placeholder INPUT TEXT" />
<br />
<br />
<br />
<textarea id="comentario" placeholder="Placeholder para TEXTAREA"></textarea>
CSS
.hasPlaceholder { color: #777; }
JavaScript
$(function placeHolder()
{
if(!$.support.placeholder)
{
var active = document.activeElement;
$('#comentario, :text').focus(function ()
{
if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder'))
{
$(this).val('').removeClass('hasPlaceholder');
}
}).blur(function ()
{
if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder')))
{
$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
}
});
$('#comentario, :text').blur();
$(active).focus();
$('form').submit(function ()
{
$(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
});
}
});