jquery localStorage for contenteditable content to remember edited content


/ Published in: jQuery
Save to your folder(s)

this shows you how to use localStorage to have a page remember content that has been edited with the html5 attribute, contenteditble


Copy this code and paste it in your HTML
  1. //demo of localStorage
  2.  
  3. $(function() {
  4.  
  5. var someSection = document.getElementById('someSection');
  6.  
  7. $(someSection).blur(function() {
  8. localStorage.setItem('toDoData', this.innerHTML);
  9. });
  10.  
  11. if(localStorage.getItem('toDoData')) {
  12. someSection.innerHTML = localStorage.getItem('toDoData');
  13. }
  14. });
  15.  
  16. <ul id="someSection" contenteditable="true">
  17. <li>add stuff here</li>
  18. </ul>

URL: http://net.tutsplus.com/tutorials/html-css-techniques/25-html5-features-tips-and-techniques-you-must-know/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.