Last active
November 5, 2016 18:34
-
-
Save shamdasani/8c264cf8703d279ab96f5e350022bf79 to your computer and use it in GitHub Desktop.
1 text editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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