When jquery submits elements whose value is not empty,
can be used for querying using
specific code :
//When executing the query, if the form field is empty, it will not be submitted
$("#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 that only one should be returned. The submit method of the form takes a bool value. If it does not return one by default, it will be void
Principle: When the form is submitted, it is based on the name attribute of the element. Yes, as long as the name attribute is not added, it will not be submitted.
The first step is to find all elements, that is, *, and then determine whether the name attribute is not null or empty.
After getting the element, then remove the name attribute if the value is empty.