我已经建立了一个待办事项清单,我希望能找到一些帮助,找出为什么我的提交文件覆盖了本地存储中现有的待办事项。
我也无法设置……
每次都会覆盖值。将值设为数组,然后尝试。
var value = []; var项目;
$("#add-to-do").on("click", function (event) { value.push($('#to-do').val().trim()), localStorage.setItem("value", JSON.stringify(value)); $("#to-do").text(JSON.parse(localStorage.getItem("value"))); //Here the full array will be received. Take the index and then add it to the element event.preventDefault(); value.push($('#to-do').val())
用于删除
var a=localStorage.getItem(value); a.pop(item) localStorage.setItem('a');