【发布时间】:2018-08-15 04:27:18
【问题描述】:
这是我的 serializeArray。我只想获取这 2 个推送属性。不需要表单中的其他元素。如何删除其他人,只保留这两个推送值(属性和操作)
var a = this.serializeArray();
a.push({name: "Attributes", value:RuleConfigs.attributeContainers});
a.push({name: "Actions", value:RuleConfigs.actionsContainers});
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
这就是我所说的。
var option=$('form').serializearray();
【问题讨论】:
-
你的问题不是很清楚。你想达到什么目标?
-
我的表单有很多字段,例如:姓名、地址、属性、操作。我想将这些属性和操作值保留在 json 数组中。但我不需要姓名和地址。如何从该数组中删除名称和地址?