Remove an item from localStorage

前端 未结 1 1730
庸人自扰
庸人自扰 2021-01-23 10:27

I\'m trying to make, a simple To-Do list in jQuery and I\'ve ran into a problem. This is my first time trying to use localStorage. So after making structure for my

相关标签:
1条回答
  • 2021-01-23 11:11

    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
    }
    

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

    0 讨论(0)
提交回复
热议问题