Skip to content

Instantly share code, notes, and snippets.

@stresslimit
Created February 19, 2011 23:48
Show Gist options
  • Save stresslimit/835520 to your computer and use it in GitHub Desktop.
Save stresslimit/835520 to your computer and use it in GitHub Desktop.
jquery input.alt toggler [mostly replaced by input placeholder=""]
// will take the alt tags from all input fields and make it the default text
// default text will disappear on focus and reappear on blur if field is blank
$('input').each(function(){
$(this).click(function(){ if(this.type=='submit') this.blur(); });
if(this.alt) {
this.value = this.alt;
this.onfocus=function(){if(this.value==this.alt){this.value='';} }
this.onblur=function(){if(this.value==''){this.value=this.alt;} }
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment