HTML Input Prompt


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



Copy this code and paste it in your HTML
  1. $('input[type=text]').each(function(){
  2. var target = $(this);
  3. if(title = target.attr('title')){
  4. if(target.val().length === 0){
  5. target.val(target.attr('title'));
  6. }
  7.  
  8. target.bind('blur', function(){
  9. if(target.val().length === 0){
  10. target.val(target.attr('title'));
  11. }
  12. });
  13.  
  14. target.bind('focus', function(){
  15. if(target.val() === target.attr('title')){
  16. target.val('');
  17. }
  18. });
  19. }
  20. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.