OnChange OnFocus Text Input with jQuery


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

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.