HTML5 localStorage 将新数据应用到已有的键中
我有以下 localStorage 键:
localStorage.setItem(1, "some data");
localStorage.setItem(2, "some data");
localStorage.setItem(3, "some data");
.
.
.
localStorage.setItem(600, "some data");
如何在循环中向这些键附加新数据?
var i = 0
for(h=0;h<600;h++) {
key = i++;
localStorage.setItem(key, "new data");
}
这将覆盖我的原始密钥,并且不会将“新数据”附加到“某些数据”。 谢谢
I have the following localStorage keys:
localStorage.setItem(1, "some data");
localStorage.setItem(2, "some data");
localStorage.setItem(3, "some data");
.
.
.
localStorage.setItem(600, "some data");
How can I append to those Keys new data in a loop?
var i = 0
for(h=0;h<600;h++) {
key = i++;
localStorage.setItem(key, "new data");
}
This will overwrite my original keys and not append the "new data" to "some data".
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
Try