The original: JS way to clear the form data two ways
Method 1: Traverse the page element/* Empty form contents id: Form id*/ function clearform (ID) { var objId = document.getElementById ( ID); if (objId = = undefined) { return; } for (var i = 0; i < objId.elements.length; i++) { if (Objid.elements[i].type = = "text") { OBJID.E Lements[i].value = ""; } else if (Objid.elements[i].type = = "Passwor D ") { Objid.elements[i].value =" "; } &NB Sp else if (Objid.elements[i].type = = "Radio") { objid.elements[i].checked = false; } else if (Objid.elements[i].type = = "checkbox") { &nbs P objid.elements[i].checked = false; } else if (Objid.elements[i].type = = "Select-one") { Objid.elements[i].optio ns[0].selected = true; } else if (Objid.elements[i].type = = "select- Multiple ") { for (var j = 0; J < Objid.elements[i].options.length; J + +) {  ; objid.elements[i].options[j].selected = false; } } else if (Objid.elements[i].type = = "textarea") {& nbsp Objid.elements[i].value = "; } / /else if (Objid.elements[i].type = = "File") { ////objid.elements[i].select (); &NB Sp ////document.selection.clear (); ////For IE, Opera, Safari, chrome //VAR file = objid.elements[i]; //if (file.outerhtml) { //File.outerh TML = file.outerhtml; //} else { //File.value = ""; FF (including 3.5) //} //} }} Method 2: Add   using the Reset button page ;<!--used to clear the form data--><input type= "reset" name= "reset" style= "display:none;"/> Trigger reset Event $ ("Input[type=reset" "). Trigger (" click ");
JS way to empty form data in two ways