0
点赞
收藏
分享

微信扫一扫

重写jquery serialize 方法

八怪不姓丑 2022-07-12 阅读 80

 

/**取表单中的对象
*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;
};

 



举报

相关推荐

方法重写

了解方法重写

方法重写(Java)

java方法重写

方法的重写

Java方法重写

0 条评论