基于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]); } }); } } } }
相关推荐
星星有所不知 2020-10-12
zuncle 2020-09-28
huaoa 2020-09-14
北京老苏 2020-08-17
luvhl 2020-08-17
Kakoola 2020-07-29
drdrsky 2020-07-29
书虫媛 2020-07-08
liaoxuewu 2020-07-08
SIMONDOMAIN 2020-07-08
爱读书的旅行者 2020-07-07
tianzyc 2020-07-04
Vue和React是数据驱动视图,如何有效控制DOM操作?能不能把计算,更多的转移为js计算?因为js执行速度很快。patch函数-->patch,对比tag,对比tag与key,对比children
Lophole 2020-07-04
Lophole 2020-06-28
liaoxuewu 2020-06-26
ApeLife技术 2020-06-26
北京老苏 2020-06-25