Home >Web Front-end >JS Tutorial >jQuery form filling example sharing
This article mainly brings you an example of form filling based on jQuery. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.
is as follows:
##
//表单填充 , 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]); } }); } } } }Related recommendations:
Detailed example of jQuery form object attribute filter selector
Detailed example of jQuery completing form validation function
Detailed example of jQuery prohibiting form user name , Password autofill function
The above is the detailed content of jQuery form filling example sharing. For more information, please follow other related articles on the PHP Chinese website!