Posted By

adriamooney on 08/04/10


Tagged

jquery html5 contentEditable localstorage


Versions (?)

jquery localStorage for contenteditable content to remember edited content


 / Published in: jQuery
 

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

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

  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>

Report this snippet  

You need to login to post a comment.