且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从localStorage删除项目

更新时间:2023-12-02 20:29:16

您应该首先检查localStorage中是否已经存在某些东西:

You should first check if something already exists in the localStorage:

if (localStorage.getItem("todolist") != null) {
    $('#todoList').html(localStorage.getItem("todolist")); // This reads items in our local storage
}

检查此更新:
http://jsbin.com/damedomepi/1/edit?html,js,输出

Check this update:
http://jsbin.com/damedomepi/1/edit?html,js,output