form表单元素的值序列化成对象

/**
 * 将form表单元素的值序列化成对象
* param: form jquery form对象
*/ var serializeObject = function(form) { var o = {}; $.each(form.serializeArray(), function(index) { if (this['value'] != undefined && this['value'].length > 0) {// 如果表单项的值非空,才进行序列化操作 if (o[this['name']]) { o[this['name']] = o[this['name']] + "," + this['value']; } else { o[this['name']] = this['value']; } } }); return o; };
原文地址:https://www.cnblogs.com/yangmengdx3/p/6322389.html