重写jquery serialize 方法

/**取表单中的对象
    *attrName:为元素的的属性名称不设置则默认为name
    */
    $.fn.serialize = function (attrName) {
        var ret = {};
        if (!attrName) {attrName = "name";}

        $(this).find("*[" + attrName + "]").each(function (i, o) {
            var thisObj = $(o);
            var attrValue = thisObj.attr(attrName);

            var curValue = null;
            if (thisObj.is(":input")) {
                if (thisObj.is(".easyui-textbox"))
                    curValue=thisObj.textbox("getValue");
                else if (thisObj.is('.easyui-combobox'))
                    curValue=thisObj.combobox("getValue");
                else
                    curValue =thisObj.val();
            }
            else {
                curValue =thisObj.text();
            }
            ret[attrValue.split(".")[0]] = curValue;
        });

        return ret;
    };
原文地址:https://www.cnblogs.com/xiaoruilin/p/7090775.html