javascript - 将索引数组添加到 localStorage

标签 javascript jquery-mobile cordova local-storage

如何将这个索引数组names添加到localStorage。并调用这个元素:

var name= new Array();

for( var i=0; i<results.rows.length; i++ ) {
    names[results.rows.item(i).IdTypePrestation ] = results.rows.item(i).LibellePrestation;
}

如果我更改此行:

names[results.rows.item(i).IdTypePrestation] = results.rows.item(i).LibellePrestation;

对此:

names[i] = results.rows.item(i).LibellePrestation;

一切都很好,但我需要第一行。

最佳答案

设置为本地存储:

localStorage.someArrayValue = JSON.stringify(myArray);

localStorage获取:

myArray = JSON.parse(localStorage.someArrayValue);

关于javascript - 将索引数组添加到 localStorage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13936667/

相关文章:

javascript - Javascript 中的可拖动和可旋转对象 (Mootools)

javascript - JQuery Mobile Changepage 更改页面而不是返回上一页

android - 将 Intent 过滤器添加到 config.xml 中,以便在 AndroidManifest.xml (Ionic 2) 中正确插入

ios - Ionic 2 cordova-plugin-mauron85-background-geolocation 不更新 UI

android - Ionic-在 Android 中从相机或画廊上传图片

javascript - 如何使用 Javascript 向左滑动

java - InnerHTML 没有给 servlet 带来值(value)

javascript - 获取div中标签文本的大小?

jquery - 如何使用 jQuery Mobile 仅支持触摸事件(无 UI 增强)?

javascript - jquery , jquery ui 和 jquery mobile 如何组合在一起