Posted By

Tate on 09/14/10


Tagged

httpwwwelectrictoolboxcomjquery-change-default-value-on-focus


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

badcircle
qubestream
lionminister


OnChange OnFocus Text Input with jQuery


 / Published in: JavaScript
 

Need to add the class .default-value to the input

  1. $j('.default-value').each(function() {
  2. var default_value = this.value;
  3. $j(this).focus(function() {
  4. if(this.value == default_value) {
  5. this.value = '';
  6. }
  7. });
  8. $j(this).blur(function() {
  9. if(this.value == '') {
  10. this.value = default_value;
  11. }
  12. });
  13. });

Report this snippet  

You need to login to post a comment.