During development, we will use many forms. We hope that the form can be reset after it is submitted.
But jquery does not have this method. How to deal with it?
Method 1:
We can implement
id:
document.getElementById("form1").reset();
name:
document.formName.reset();
Method 2:
Clear one by one:
$("#inp").val("1");
But if there are too many forms, this is not practical. There are 100 or 1000. You can’t write 100 or 1000.
Maybe you will say, write it like this:
$ ("input").val("");
What about the default value of the form? There are other types of forms, write them all?
Add input of type reset
$("input[name='res']").click();
Clear all forms
ok
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn