<!DOCTYPE html> <html> <head> <script> var version = 0; function saveEdits() { var editElem = document.getElementById("edit"); version = localStorage.getItem("v"); var versionTxt = document.createTextNode("Version " + localStorage.getItem("v")) document.body.appendChild(versionTxt); version++ localStorage.setItem("v", version); localStorage.setItem("Elm", editElem.innerHTML); document.getElementById("update").innerHTML="Edits saved!"; } var editedElem = document.getElementById("edit"); var edits = localStorage.getItem("Elm"); editedElem.innerHTML = edits; </script> </head> <body> <div id="edit" contenteditable="true"> Edit me </div> <button onclick="saveEdits()">save edits</button> <div id="update"> - Edit the text and click to save for next time</div> </body> </html>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter