Skip to content

Instantly share code, notes, and snippets.

@shamdasani
Last active November 5, 2016 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shamdasani/8c264cf8703d279ab96f5e350022bf79 to your computer and use it in GitHub Desktop.
Save shamdasani/8c264cf8703d279ab96f5e350022bf79 to your computer and use it in GitHub Desktop.
1 text editor
document.getElementById('heading').innerHTML = localStorage['title'] || 'Just Write'; // default text
document.getElementById('content').innerHTML = localStorage['text'] || 'This text is automatically saved every second :) '; // default text
setInterval(function() { // fuction that is saving the innerHTML of the div
localStorage['title'] = document.getElementById('heading').innerHTML; // heading div
localStorage['text'] = document.getElementById('content').innerHTML; // content div
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment