Home >Web Front-end >JS Tutorial >There are too many fields. jquey method to quickly clear the form content_jquery
I made a complex query page with too many fields. It was very troublesome to fill it in once and clear it out
$('#myform')[0].reset();
Although the reset method can do part of it, if you have an element like this
<input name="percent" value="50"/>
Then clicking reset will only restore it to 50
So, with the following method, browse online,
$(':input','#myform') .not(':button, :submit, :reset, :hidden') .val('') .removeAttr('checked') .removeAttr('selected');