jquery commits an element that is not empty
can be used to query when using the
Specific code :
Copy Code code as follows:
When the query is executed, if the form's fields are empty, they are not committed
$ ("#form1"). Submit (function () {
try {
$ (this). Find ("*"). each (function () {
var Elem = $ (this);
if (Elem.prop ("name")!= null&&elem.prop ("name")!= "") {
if (elem.val () = = "") {
Elem.removeattr ("name");
}
}
});
}catch (e) {
Alert (e);
}
return true;
});
Note To return only, the form's Submit method takes the bool value, if not the default return one, then is void
principle : When a form is submitted, it is based on the attribute of the element's name, and is not committed as long as the name attribute is not added.
The first step is to find all the elements that are *, and then to determine that the Name property is not NULL or null
The Name property is removed after the element is taken, and the value is empty.