Skip to content

Instantly share code, notes, and snippets.

@andershaig
Created September 26, 2011 18:22
Show Gist options
  • Save andershaig/1242944 to your computer and use it in GitHub Desktop.
Save andershaig/1242944 to your computer and use it in GitHub Desktop.
Store Values on Page Load, Replace When Empty
<script type="text/javascript">
$(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');
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment