$(function() { if (!('placeholder' in document.createElement('input'))) { $('input[placeholder], textarea[placeholder]').each(function() { var text = this.getAttribute('placeholder'); var fld = $(this); function setPlaceholder() { if (fld.value == text || fld.value == '') { fld.addClass('jqPlaceholder'); fld.val(text); } } function removePlaceholder() { if (fld.value == text || fld.value == '') { fld.val(''); fld.removeClass('jqPlaceholder'); } } setPlaceholder(); $(this).focus(removePlacholder); $(this).blur(setPlaceholder); $(this).parents("form").submit(removePlacholder); }); } });