首页 > 其他 > 详细

自定义$('#form').serialize() var params = $('#xxx_form').serializeObject();

时间:2018-05-16 10:17:37      阅读:481      评论:0      收藏:0      [点我收藏+]
 //注意:获取之前 $("#id").removeAttr("disabled");
 $.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 || ‘‘;
            }
        });
        var $radio = $(‘input[type=radio],input[type=checkbox]‘, this);
        $.each($radio, function () {
            if (!o.hasOwnProperty(this.name)) {
                o[this.name] = ‘‘;
            }
        });
        return o;
    };

 

自定义$('#form').serialize() var params = $('#xxx_form').serializeObject();

原文:https://www.cnblogs.com/hahajava/p/9044361.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!