javascript~将表单元素序列化为对象格式{"":"",....}

$.fn.serializeObject = function () {
var o = {};
var a = this.serializeArray();
$.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;
};

引用:https://segmentfault.com/a/1190000006154289

猜你喜欢

转载自blog.csdn.net/zf18234031156/article/details/89400428
今日推荐