首页 > 语言 > JavaScript > 正文

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

2024-05-06 14:28:47
字体:
来源:转载
供稿:网友
代码如下:
$.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;
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选