龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Javascript编程 >

jquery form表单序列化为对象的示例代码

时间:2014-06-09 10:13来源:网络整理 作者:网络 点击:
分享到:
这篇文章主要介绍了jquery form表单序列化为对象具体实现,需要的朋友可以参考下
代码如下:

$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
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;
}
精彩图集

赞助商链接