HTML5本地存储实例页面

代码:

HTML代码:
<ul id="edit" contenteditable="true">
    <li>修改我吧,然后刷新页面看看,^_^</li>
</ul>
                
JS代码:
var edit = document.getElementById("edit");
edit.onblur = function(){
    localStorage.setItem("tododata", this.innerHTML);
};
if(localStorage.getItem("tododata")){
    edit.innerHTML = localStorage.getItem("tododata");	
}
                

效果:

  • 修改我吧,然后刷新页面看看,^_^