Search field content control


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



Copy this code and paste it in your HTML
  1. //
  2. // Search form control function
  3. //
  4.  
  5. $(document).ready(function(){
  6.  
  7. // Get default search box value from hidden label
  8. $("#keywords").attr("value", $("#search label").text());
  9.  
  10. // Clear search box only if default value present
  11. $("#keywords").focus(function(){
  12. if ($(this).attr("value") == $("#search label").text()) {
  13. $(this).attr("value", "");
  14. }
  15. });
  16.  
  17. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.