Sometimes you might want to do this by submitting the form with Ajax, emptying the form after the form has been successfully submitted, and following this code:
Copy Code code as follows:
<form>
<input name= "Name1"/><br/>
<input name= "Name1"/><br/>
<textarea name= "Content" ></textarea>
<a href= "javascript:void (0)" onclick= "subform ()" > Submit </a>
</form>
After clicking Submit, the content is submitted via Ajax.
I used the following code to clear the form
Copy Code code as follows:
$ ("input"). Val (');
$ ("textarea"). Val (');
The previous days have no intention of thinking of another method (if you know the following method friends can stop there):
Copy Code code as follows:
Add a hidden reset button to the form form.
<input type= "reset" style= "display:none;"/>
And then the reset button is triggered by trigger.
Function Subform () {
/* ...
* Part of the code that submits the form
* ... */
$ ("Input[type=reset]"). Trigger ("click");//Trigger Reset Button}