【发布时间】:2016-05-03 09:07:53
【问题描述】:
您好,我正在尝试在本地存储中保存一些 input[type="text"] 和 input[type="hidden"] 值。下面是JS:
$('.proceed_btn').on('click', function(){
$('input[type="text"]').each(function(){
var id = $(this).attr('id');
var value = $(this).val();
localStorage.setItem(id, value);
});
$('input[type="hidden"]').each(function(){
var id = $(this).attr('id');
var value = $(this).val();
localStorage.setItem(id, value);
});
});
价值得到完美存储。但我想以 json 格式存储这些值。但是如何将这两个值保存在一个变量中。例如:
order: {
id: '',
product: '',
service: '',
name: ''
}
我已经检查了 JSON 字符串化,但是如何同时使用不同类型的输入来实现
【问题讨论】:
-
我在尝试忘记删除代码。
标签: javascript jquery