Skip to content

Instantly share code, notes, and snippets.

@trentsnippets
Last active December 19, 2015 12:28
Show Gist options
  • Save trentsnippets/5954617 to your computer and use it in GitHub Desktop.
Save trentsnippets/5954617 to your computer and use it in GitHub Desktop.
This jQuery code will make form values show / hide on click so you can use them as titles.
$(document).ready(function(){
$('form input:text, form textarea').each(function(){
$.data(this, 'default', this.value);
}).focus(function(){
if ($.data(this, 'default') == this.value) {
this.value = '';
}
}).blur(function(){
if (this.value === '') {
this.value = $.data(this, 'default');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment