Posted By

prsjohnny on 08/11/10


Tagged

js search forms jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jearley


Textbox place holder


 / Published in: jQuery
 

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

  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  

You need to login to post a comment.