Using jQuery to reset the of reset form

  • 2020-03-30 02:51:44
  • OfStack

Due to JQuery, the submission form looks like this:

$('#yigeform').submit()


So, of course, resetting the form looks like this:
$('#yigeform').reset()


But, unfortunately, there's one frustrating result of writing this: the form can't be reset!

Later, check the Internet, said that there is no reset method in JQuery, after checking, as expected is no.

There is no way to reset the form through JQuery. The answer is yes, but it is an indirect way, as follows:

$('#yigeform')[0].reset()

That is, you reset the form by calling the reset method in the DOM.


Related articles: