简体   繁体   English

将动态数据保存在html5中的localstorage中?

[英]saving dynamic data in localstorage in html5?

In my mobile app (jquery mobile + phonegap), I have two select menus and when user select some options from that menus, I want to store that in local storage. 在我的移动应用程序(jquery mobile + phonegap)中,我有两个选择菜单,当用户从菜单中选择某些选项时,我想将其存储在本地存储中。 I know the simple syntax of local storage like localStorage.setItem(key,value); 我知道本地存储的简单语法,例如localStorage.setItem(key,value); But i have no idea how to store dynamic data in local storage? 但是我不知道如何在本地存储中存储动态数据?

Dynamic meaning what? 动态含义是什么?

For it to be "dynamic" then just update the localStorage item by running localStorage.setItem(key,value) using the same key and updating the value. 为了使其“动态”,只需使用相同的键运行localStorage.setItem(key,value)并更新值即可更新localStorage项。

Make a function which gets all of the menus items and values (off or on, 0 or 1, false or true, or some string/integer) which runs localStorage.setItem(key,value) then call that function every time the menu is saved or updated. 创建一个获取所有菜单项和值(off或on,0或1,false或true或某些字符串/整数)或运行localStorage.setItem(key,value)函数localStorage.setItem(key,value)然后在每次菜单显示时调用该函数保存或更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM