Posted By

adambundy on 12/15/09


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

adambundy
lanceguyatt


clear textfield value, replace


 / Published in: jQuery
 

  1. $(document).ready(function() {
  2. //attach function to input and make text grayed out on page load
  3. textReplacement($('#query').css("color", "#999"));
  4. });
  5.  
  6. // the function:
  7. function textReplacement(input){ //input focus text function
  8. var originalvalue = input.val();
  9. input.focus( function(){
  10. if( $.trim(input.val()) == originalvalue ){ input.val('').css("color", "#000"); }
  11. });
  12. input.blur( function(){
  13. if( $.trim(input.val()) == '' ){ input.val(originalvalue).css("color", "#999"); }
  14. });
  15. }

Report this snippet  

You need to login to post a comment.