Placeholder IE7 Script


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $('[placeholder]').focus(function() {
  2. var input = $(this);
  3. if (input.val() == input.attr('placeholder')) {
  4. input.val('');
  5. input.removeClass('placeholder');
  6. }
  7. }).blur(function() {
  8. var input = $(this);
  9. if (input.val() == '' || input.val() == input.attr('placeholder')) {
  10. input.addClass('placeholder');
  11. input.val(input.attr('placeholder'));
  12. }
  13. }).blur().parents('form').submit(function() {
  14. $(this).find('[placeholder]').each(function() {
  15. var input = $(this);
  16. if (input.val() == input.attr('placeholder')) {
  17. input.val('');
  18. }
  19. });
  20. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.