2012-04-06 122 views
0

我有:
localStorage.xxx = JSON.stringify([["something","hello"],["something2","hello2"]]);
如何添加JSON xxx中的新陣列,如["something3","hello3"]將元素添加到localStorage中的json

+0

你把它放回localStorage的前再次尋找的東西比分析保存在localStorage的json的,修改你的對象/數組,字符串化則是更聰明? – kinakuta 2012-04-06 09:38:58

回答

2

你的意思是這樣的:


var arr = JSON.parse(localStorage.xxx) ; 
arr.push(["something3","hello3"]) ; 
localStorage.xxx = JSON.stringify(arr) ;