问题描述
- localStorage存储和读取表单
-
问题如题,怎样用localStorage存储一个表单数据,主要是不知道怎样用JSON存储,求大神指教!
解决方案
LocalStorage存储
本地存储localstorage
localstorage存储
解决方案二:
http://blog.csdn.net/my_yang/article/details/7955523
解决方案三:
localstorage本身就是键值对,跟JSON是对应的
var printStorageBody = function(){
$("body").html("");
for(var i=0;i<localStorage.length -1;i++)
$("body").append(i + " : " + localStorage.getItem(localStorage.key(i)) + "<br />");
};
memories = localStorage.getItem('memories') ?
JSON.parse(localStorage.getItem('memories')) :
[];
memories.push(myMemory);
localStorage.setItem('memories', JSON.stringify(memories));
时间: 2024-12-03 07:23:20