shah rushabh shah rushabh - 2 months ago 8
HTML Question

How to clear form data jquery?

I want to clear all form input data after a submitting all input data to php file how can I clear this data by using jquery function?

Answer

You can listen to the submit event and then clear the values of each input like below:

$('#form').submit(function() {
  $(this)[0].reset();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="form">
  <input type="text" />
  <input type="submit" />
</form>

Comments