时间:2021-09-03 09:19:27 | 栏目:jquery | 点击:次
如下所示:
//表单填充 , formDataLoad: function (domId, obj) { for (var property in obj) { if (obj.hasOwnProperty(property) == true) { if ($("#" + domId + " [name='" + property + "']").size() > 0) { $("#" + domId + " [name='" + property + "']").each(function () { var dom = this; if ($(dom).attr("type") == "radio") { $(dom).filter("[value='" + obj[property] + "']").attr("checked", true); } if ($(dom).attr("type") == "checkbox") { obj[property] == true ? $(dom).attr("checked", "checked") : $(dom).attr("checked", "checked").removeAttr("checked"); } if ($(dom).attr("type") == "text" || $(dom).prop("tagName") == "SELECT" || $(dom).attr("type") == "hidden" || $(dom).attr("type") == "textarea") { $(dom).val(obj[property]); } if ($(dom).prop("tagName") == "TEXTAREA") { $(dom).val(obj[property]); } }); } } } }