Textbox place holder


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

Display a default value in a text field that disappears on focus and reappears on blur **if** the field is blank.


Copy this code and paste it in your HTML
  1. if($(input).val() == ""){
  2. $(input).val("Search Here...");
  3. }
  4.  
  5. $(input).focus(function(){
  6. if($(input).val() == "Search Here..."){
  7. $(this).val("");
  8. }
  9. });
  10.  
  11. $(input).blur(function(){
  12. if($(input).val() == ""){
  13. $(input).val("Search Here...");
  14. }
  15. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.