Skip to content

Instantly share code, notes, and snippets.

@zackify
Created August 28, 2011 23:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackify/1177422 to your computer and use it in GitHub Desktop.
Save zackify/1177422 to your computer and use it in GitHub Desktop.
Auto loading and saving for content
<script type="text/javascript">
$(document).ready(function(){
var edit = document.getElementById('edit');
$(edit).blur(function() {
localStorage.setItem('todoData', this.innerHTML);
});
// when the page loads
if ( localStorage.getItem('todoData') ) {
edit.innerHTML = localStorage.getItem('todoData');
}
// to reset
// localStorage.clear();
setInterval('save()',200);
});
function save(){
var edit = document.getElementById('edit');
localStorage.setItem('todoData', edit.innerHTML);
// to reset
// localStorage.clear();
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment