Search Input text


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



Copy this code and paste it in your HTML
  1. // Put text in the search box and remove it and change the colour when it needs to be used.
  2. function search_text()
  3. {
  4. var search_advice_text = $('#f_search').siblings('label').text();
  5.  
  6.  
  7. $('#f_search').val( search_advice_text ).css({'color':'#ccc'});
  8.  
  9. $('#f_search').focus(function(){
  10. if( $(this).val().length == 0 || $(this).val() == search_advice_text ){
  11. $(this).val( '' ).css({'color':'#444'});
  12. }
  13. }).blur(function(){
  14.  
  15.  
  16. if( $(this).val().length == 0 ){
  17. $(this).val( search_advice_text ).css({'color':'#ccc'});
  18. }
  19. });
  20.  
  21. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.