欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

将form表单中的元素转换成对象的方法适用表单提交_javascript技巧

程序员文章站 2022-05-27 23:21:32
...
复制代码 代码如下:

function serializeObject(form){
var o ={};
$.each(form.serializeArray(),function(index){
if(o[this['name']]){
o[this['name']] = o[this['name']] +","+this['value'];
}else{
o[this['name']] = this['value'];
}
});
return o;
}