|
|
Модератор форума: Yuri_G |
Сообщество uCoz » Архивариус » Решённые вопросы » Как добавить в input > placeholder |
Как добавить в input > placeholder |
mick-3k, наведу пример как я использую placeholder в почтовых формах:
Цитата <input type="text" name="f2" size="30" style="width:95%;" maxlength="70" placeholder="Тема"> Код <script> $(function(){ jQuery.support.placeholder = false; test = document.createElement('input'); if('placeholder' in test) jQuery.support.placeholder = true; if(!jQuery.support.placeholder) { var active = document.activeElement; $(':text, textarea').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'); } };); $(':text, textarea').blur(); $(active).focus(); $('form').submit(function () { $(this).find('.hasPlaceholder').each(function() { $(this).val(''); };); };); } };); </script> |
|
| |||
| |||